Quantcast
Channel: Active questions tagged nuget-package - Stack Overflow
Viewing all articles
Browse latest Browse all 3067

Nuget Library .exe's are not Appearing In Main Project

$
0
0

I have been at this for over a week now and I am still having no luck.

Here is what I am trying to achieve in short -

I have a Nuget library that contains two .exe files that only the library uses. The problem is, that when the library is pulled into the main project, the exes are either not being put in the output folder properly, or the path to them is turning into the main project path instead of the nuget/lib path.

The Library

Here is the .csproj

<ItemGroup><Content Include="Drivers/**"><Pack>true</Pack><PackagePath>lib\net5.0\Drivers\</PackagePath><CopyToOutputDirectory>Always</CopyToOutputDirectory><CopyToPublishDirectory>Always</CopyToPublishDirectory><PackageCopyToOutput>Always</PackageCopyToOutput></Content></ItemGroup>

How I am using the exe's in the library's code -

var path = $"{AppDomain.CurrentDomain.BaseDirectory}Drivers";

This successfully packs up my project and allows me to use the exe's when I run the unit tests on our packaging pipelines. When downloaded into the new project, it creates a nuget directory with the path

{USER}\.nuget\packages\drivers.library\1.0.X

In that directory there are three folders

--content (contains testhost stuff)--contentFiles (contains testhost stuff)--lib   \ net5.0         \ Drivers             \ exe1 and exe2  

The Main Project

So after importing the library

<PackageReference Include="Drivers.Framework" Version="1.0.8" />

I would of expected the "Drivers" folder to be built into the OutputDirectory of the main project based on the settings that were in the library's .csproj file.

I would of also expected that using AppDomain.CurrentDomain.BaseDirectory in the library would of defaulted to the location where the .dll is located in the .nuget directory.

However, that's obviously not the case.

As far as trying to get the .dll location, I've tried -

"1" + Assembly.GetExecutingAssembly().Location; "2" + Assembly.GetExecutingAssembly().CodeBase; "3" + AppDomain.CurrentDomain.BaseDirectory;"4" + AppDomain.CurrentDomain.DynamicDirectory;"5" + AppDomain.CurrentDomain.FriendlyName;"6" + AppDomain.CurrentDomain.RelativeSearchPath;

but it all points to where the main project is and not the library.

As far as getting the Drivers folder from the .nuget directory to the main project's output folder. I've tried some recursion in the csproj, but I was only able to grab the dependency .dlls and not the exes. I have also seen some people use powershell, but I would like to absolutely avoid that if possible.

If anyone has any idea of how to get the nuget/lib/Drivers folder to build into the Main project's output folder, I would be forever grateful.

Thank you guys.


Viewing all articles
Browse latest Browse all 3067

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>