DLL in NuGet package not appearing in build output folder - c#

We have a NuGet package that was created by ourselves and is hosted on an in-house repo. We've been using it for several years in a .Net Framework 4.x solution. The package contains a .Net4.x assembly (a class library, referenced by code in the solution), two "native" DLLs, and a handful of .c files. When the solution builds, every file in the package gets copied to the build output folder, which is what we expect.
I've now migrated this solution to .Net6 and referencing the same package, but the build behaviour is different. Here, the solution builds successfully but none of the files in the package get copied to the build output folder. Instead, the two native DLLs and .c files get copied to the root folder of the referencing project (also showing up in the VS solution explorer window). The .Net assembly (TspAdqAcquisition.dll) does not appear in the project root folder, or anywhere else for that matter.
What's going on?
This is the nuspec file (from the "library" solution where the Tsp...dll and other files reside):
<?xml version="1.0" encoding="utf-8"?>
<package >
<metadata minClientVersion="2.5">
....
</metadata>
<files>
<file src="x64\Release\*.c" target="build" />
<file src="x64\Release\glew64.dll" target="build\glew64.dll" />
<file src="x64\Release\glut64.dll" target="build\glut64.dll" />
<file src="x64\Release\TspAdqAcquisition.dll" target="lib\net451\TspAdqAcquisition.dll" />
<file src="x64\Release\TspAdqAcquisition.dll" target="lib\net\TspAdqAcquisition.dll" />
<file src="x64\Release\TspAdqAcquisition.dll" target="lib\net6.0\TspAdqAcquisition.dll" />
<file src="x64\Release\TspAdqAcquisition.dll" target="lib\net6.0-windows10\TspAdqAcquisition.dll" />
<file src="x64\Release\TspAdqAcquisition.dll" target="lib\net6.0-windows11\TspAdqAcquisition.dll" />
</files>
</package>
Edit
I've figured out why the two native DLLs and .c files weren't being copied to the build output folder. The NuGet package in question is referenced by a class library project (net6.0 TFM rather than net6.0-windows), so these particular files were ending up in a separate \net6.0\ build output folder, rather than the \net6.0-windows\ build output folder that the rest of the solution ends up in. Once I'd referenced that class library project by one of the WPF projects, these files appeared in the correct build output folder.
However the TspAdqAcquisition.dll assembly still isn't being copied to (either) build output folder.
Edit 2
I'm now able to get the TspAdqAcquisition.dll assembly to copy to the build output folder by including this line in the project file:
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
I had to put this in the WPF project file to ensure that the DLL is copied to the correct (\net6.0-windows) build output folder. If I add the above line to the class library project file referencing the NuGet package then the DLL ends up in the wrong (\net6.0) build output folder.
It's all starting to feel a bit hacky for my liking...
My last remaining question then is whether it's possible to prevent those native DLLs and .c files from being "unpackaged" into the project folder and cluttering up the solution explorer window? Why doesn't this happen in VS2019?

It seems you don't have a .targets file in the nuget package. I'm not sure whether that's the "normal" way of how this should be done, but that's how I copy native binaries to the output.
So one possible way to get this to work correctly, is to create a <packagename>.targets file in the build folder of the nuget with content such as:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="CopyFilesToTargetDirectory_MyPackageName" BeforeTargets="Build">
<ItemGroup>
<FilesForTargetDirectory_MyPackageName Include="$(MSBuildThisFileDirectory)\..\tools\**\*.*" />
</ItemGroup>
<PropertyGroup>
<TargetDirectory_MyPackageName Condition="'$(TargetDirectory_MyPackageName)' == ''">$(TargetDir)</TargetDirectory_MyPackageName>
</PropertyGroup>
<Copy SourceFiles="#(FilesForTargetDirectory_MyPackageName)"
DestinationFolder="$(TargetDirectory_MyPackageName)\%(RecursiveDir)"
SkipUnchangedFiles="true" />
</Target>
</Project>
and then, move the native libraries from the build folder to either the tools folder (as in the example code above) or the lib\native folder.

Related

Include ONLY .xml file of SPECIFIC nuget package in a different folder

We have a project (ProjectAbc) in a solution which is referencing a nuget package (which is our different project [ProjectXyz] from other solution). We use .net core framework and package reference to include nuget package (ProjectXyz) in .csproj file.
<PackageReference Include="ProjectXyz" Version="1.1.2.3" />
When the solution is build locally or in Prod, ProjectXyz.dll and ProjectXyz.xml gets generated in
ProjectAbc/bin/debug(locally) or release(inProd)/netcoreapp3.1
We want Only ProjectXyz.xml of Only ProjectXyz nuget package to get generated in following folder directly
ProjectAbc
I found various articles which directed me to do different things like copying file to output directory after building or using relative path. Though, tried different ways, I keep getting various errors. It may be because I am not aware of the syntax in .csproj file or also may be because I am not sure what I am doing.
What would be best way to copy file in above case or to generate file directly in the required folder?
for my comment response:
Since I am unable to paste the screenshot in my comment for #Perry Qian-MSFT. So pasting it here.
8/20/2020-----package screenshot---------------------------
You could use <package_name>.props file in nuget project ProjectXyz to copy such file into the project folder of ProjectAbc. You should use <package_id>.props.
1) First, in your ProjectXyz project, create a folder called build and then add a file called <package_id>.props, in your side, it is called ProjectXyz.props.
2) Add these in ProjectXyz.props file:
<Project>
<Target Name="CopyFilesToProject" BeforeTargets="Build">
<Message Text="Copying ProjectXyz.xml to project" />
<ItemGroup>
<SourceScripts Include="$(MSBuildThisFileDirectory)..\..\content\any\any\**\*.*"/> //file from the ProjectXyz nuget package
</ItemGroup>
<Copy
SourceFiles="#(SourceScripts)"
DestinationFiles="#(SourceScripts -> '$(MSBuildProjectDirectory)\%(RecursiveDir)%(Filename)%(Extension)')" //copy into the main ProjectAbc project folder
/>
</Target>
</Project>
3) Unload your ProjectXyz project and add these in ProjectXyz.csproj file:
<ItemGroup>
<Content Include="bin\Debug\xxx\ProjectXyz.xml(the path of the ProjectXyz.xml)" Pack="true"
PackagePath="content\any\any;contentFiles\any\any\;;">
<PackageCopyToOutput>true</PackageCopyToOutput>
</Content>
<None Include="build\ProjectXyz.props" Pack="true" PackagePath="build\$(TargetFramework)"/>
</ItemGroup>
4) Then you should pack your new ProjectXyz project.
5) Then you finish packing, you should first clean all nuget caches first.
Then in your ProjectAbc project, you should uninstall the old one and then install the new ProjectXyz nuget package.
After that, you should build ProjectAbc project first and then you will see that xml document from the nuget package is under the project folder of ProjectAbc.
====================================================================
Update 1
ProjectXyz project is net core or net standard while ProjectAbc is net core.
First, to help you understand the issue, instead, I try to pack ProjectXyz.xml file into other folder in the ProjectXyz.nupkg.
1) First, change to use these xml content in ProjectXyz.csproj file:
<ItemGroup>
<Content Include="bin\Debug\netcoreapp3.1\ProjectXyz.xml" Pack="true" PackagePath="XmlFolder">
<PackageCopyToOutput>true</PackageCopyToOutput>
</Content>
<None Include="build\ProjectXyz.props" Pack="true" PackagePath="build\$(TargetFramework)"/>
</ItemGroup>
The goal of it is to pack ProjectXyz.xml file into the folder called XmlFolder of XmlFolder.nupkg. And save ProjectXyz.xml file in the Nuget package.
Make sure that the file exists in the nuget package.
If the file does not exist, I think it is controlled by your git. Or you could put this ProjectXyz.xml in your project folder.
Try to right-click on your project-->Properties-->Build-->check this:
Just use <Content Include="ProjectXyz.xml" Pack="true" PackagePath="XmlFolder">
In our side, the file can be copied into nupkg nuget package so you should make sure that other tools like git will not interface it.
2) Then change to use these in ProjectXyz.props file:
<Project>
<Target Name="CopyFilesToProject" BeforeTargets="Build">
<Message Text="Copying ProjectXyz.xml to project" />
<ItemGroup>
//ProjectXyz.xml file from the ProjectXyz nuget package
<SourceScripts Include="$(MSBuildThisFileDirectory)..\..\XmlFolder\**\*.*"/>
</ItemGroup>
//copy ProjectXyz.xml file into the main ProjectAbc project folder
<Copy
SourceFiles="#(SourceScripts)"
DestinationFiles="#(SourceScripts -> '$(MSBuildProjectDirectory)\%(RecursiveDir)%(Filename)%(Extension)')"
/>
</Target>
</Project>
The goal of it is that when you install this nuget package, it will first run this target to copy the ProjectXyz.xml file from the nuget package into the main project ProjectAbc.
Note:
When you finishing installing nuget package, first build ProjectAbc project and the file will exists in ProjectAbc project folder.
3) Then right-click ProjectXyz-->Properties-->Pack to pack your project.
When you install the new ProjectXyz, you should first delete all files under
C:\Users\xxx(current user)\.nuget\packages.
Also, one more question I had is, the ProjectXyz is being referenced
in multiple projects like ProjectAbc, Project123. We dont want
ProjectXyz.xml file to show up in Project123 but only in ProjectAbc. I
guess with above solution, it might show in both of referencing
projects.
For this, you only need to add a condition in CopyFilesToProject target like this: $(ProjectXyz_Flag)==true and then create a property ProjectXyz_Flag and set its value to true in ProjectAbc.csproj file.
When you build ProjectAbc project, it will determine whether to copy the file based on the switch variable you are currently setting.
a) Add a condition called $(ProjectXyz_Flag) in ProjectXyz.props file:
Then repack your ProjectXyz project and do several clean steps as I said before.
When you install that package in ProjectAbc project, you should add such such property in ProjectAbc.csproj file:
<PropertyGroup>
<ProjectXyz_Flag>true</ProjectXyz_Flag>
</PropertyGroup>
Then when you build ProjectAbc project, it will execute the copy target and if you do not define that property, it will not copy that file in ProjectAbc.
And if those projects do not need ProjectXyz.xml file, you just do not define that switch property in those projects.
====================================================
Update 2
try to use nuget.exe cli to pack your project, you just need a custom nuspec file:
First, download nuget.exe cli and then configure its local path into PATH System Environment Variable. Then, you can call nuget in CMD.
Second, open CMD and cd xxx(project folder path), run nuget spec to generate the nuspec file and then modify the generated nuspec file:
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<!-- ... -->
</metadata>
<files>
<file src="xxx\ProjectXyz.xml" target="XmlFolder" />
<file src="build\ProjectXyz.props" target="build\netcoreapp3.1" />
</files>
</package>
Third, run nuget pack to pack this project.
==============================================================
Update 3
Please first clean your nuget caches or just delete all nuget caches under C:\Users\xxx(current user)\.nuget\packages. Then reinstall your nuget package.
Also, make sure that the xxx.props name is the same as your nuget package_id.
If your nuget package calls ProjectXyz(package_id). Then the props file should be named as ProjectXyz.props.
Besides, you should set msbuild project build output verbosity to detailed under Tools-->Options-->Projects and Solutions-->Build and Run.
Then, rebuild your ProjectAbc to check whether the target executes.
======================================================
Update 4
You should make sure that when you pack your package project.mnop, make sure that the project.mnop.props file has no syntax errors.
For an example, I have incorrectly wrote something like asdczxcx in the props file, however, since the build action of the props file is Content or None, Vs will not automatically analyze its errors and will not show the errors.
And the error shows the same as yours.
So you should delete that Illegal characters. Make sure that project.mnop.props has no syntax errors. Then repack your project.
After that, first uninstall the old nuget package project.mnop on the ProjectAbc.
Then, delete the cache project.mnop folder under C:\Users\xxx(current user)\.nuget\packages.
Finally, delete bin and obj folder of ProjectAbc, install the new version project.mnop, then rebuild your project ProjectAbc.
=============================================
Update 5
Actually, this should be an easier way. And your inspiration can be done with a more concise Nuget package structure.
You should only change this:
1) change to use ProjectXyz.xml from the lib folder in your ProjectXyz.props:
<SourceScripts Include="$(MSBuildThisFileDirectory)..\..\lib\netcoreapp3.1\ProjectXyz.xml"/>
</ItemGroup>
<Copy
SourceFiles="#(SourceScripts)"
DestinationFiles="#(SourceScripts -> '$(MSBuildProjectDirectory)\%(RecursiveDir)%(Filename)%(Extension)')"
/>
2) change your xxx.nuspec file to:
<?xml version="1.0"?>
<package >
<metadata>
........
<copyright>Copyright 2020</copyright>
<tags>Tag1 Tag2</tags>
</metadata>
<files>
<file src="build\ProjectXyz.props" target="build\netcoreapp3.1" />
</files>
</package>
3) then pack your project and then you can get what you want.
Note: SourceScripts uses the path $(MSBuildThisFileDirectory).
$(MSBuildThisFileDirectory) means the full path where the ProjectXyz.props file of the nuget package exists.
In your side, the $(MSBuildThisFileDirectory) means
C:\Users\xxxxx\.nuget\packages\project.mnop\45.0.0\build\netcoreapp3.1
And then use this path to find the file address of ProjectXyz.xml in the lib folder of the nuget package.

Set build action of file copied to project in nuget

I have a nuget package that copies files into the target project - this is done by adding the following to the nuget project file:
<Content Include="Views\Error\Links-Example.cshtml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
And this will copy the view to the target project views folder
Is there a way to set the build action to none for this copied file (other than manually doing it once it's been copied)?
Is there a way to set the build action to none for this copied file
(other than manually doing it once it's been copied)?
It seems what you want is: When one project consumes this package, that file should exist in VS Solution Explorer, and its build action should be None.
For this, you could use custom nuspec file when generating the nuget package. Change the Content to None for your script, and add similar content like mine below into xx.nuspec file:
<metadata>
...
<contentFiles>
<files include="any/any/Views/Error/controller1.js" buildAction="None" copyToOutput="false" flatten="true" />
</contentFiles>
</metadata>
<files>
<file src="relativePath/controller1.js" target="contentFiles/any/any/Views/Error/" />
</files>
You can specify the build action of one file in files element. And if this package targets .net framework projects, use Content instead of ContentFiles element.
Then, the copied file's build action can be None when the package is consumed:

How to copy a text file from NuGet package during build of C# code that uses the package?

How do you copy a text file that has been included along with the DLLs within a NuGet package?
When I use my custom NuGet package in another solution (c:\dev\ for this example), the resulting file structure within c:\dev\package\projectId\lib\netstandard2.0\ has many DLLs and a text file, say file.txt. The DLLs are all copied upon building the solution, but the text file is left behind.
Within the .nuspec file, I originally included the file under <files><file src="foo\file.txt" target="lib\netstandard2.0"/></files>. The file.txt ends up in the packages folder when the NuGet package is restored, but it's not copied into the build directory.
Attempt 1: I tried using the contentFiles property within the nuspec file, since the nuspec reference points there a few times. I got nuget.exe pack command to work with this new property (i.e. no syntax errors), but there was no change in how the content (file.txt) was handled.
Attempt 2: I tried using a projectId.targets file. This uses a Target that has an ItemGroup that includes the file. Then, I tried using a Copy event, pointing to the destination folder as $(OutputPath).
It seems awfully hard to copy a file that is included in the package to the build directory, having to dive into MSBuild events and the like.
I'm at a loss here, and any pointers would be welcome.
Edits # 1:
I tried adding this section to the metadata, per a suggestion below:
<contentFiles>
<files include="any\any\file.txt" buildAction="EmbeddedResource" />
</contentFiles>
This works in a small test case. The file.txt shows up nicely in both Visual Studio and in the build directory. Weirdly, it doesn't work in my main project using the same exact syntax (I'm using .NET Core 2.0 in both). Also, in NuGet Package Explorer, it shows up in the package contents when it's alone. But when I add something under <files><file src="lib\netstandard2.0\test.dll" target="lib\netstandard2.0"/></files>, it disappears from that view.
Edits # 2:
I think there's something else going on... Here is the .nuspec file from our main project. When I add a content file with the working suggestions below, it still doesn't show up (for either .NET Core 2.0 or .NET Framework 4.7.1). Is the .targets file messing this up somehow?
How to copy a text file from NuGet package during build of C# code that uses the package?
You should use contentFiles property and set copyToOutput="true" for the text file file.txt.
My test .nuspec file:
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>MyTestCore</id>
<version>5.0.0</version>
<authors>TestContentFile</authors>
<owners>TestContentFile</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Package Description</description>
<contentFiles>
<files include="any/any/file.txt" buildAction="content" flatten="true" copyToOutput="true"/>
</contentFiles>
</metadata>
<files>
<file src="contentFiles/any/any/file.txt" target="contentFiles/any/any" />
</files>
</package>
After pack this .nuspec file, then add the nuget package to the project, build the project, the text file will copy to the build directory:
Check the update answer for the similar issue for some more details.
You have to define build action to the file.
<contentFiles>
<!-- Include Assets as Content -->
<files include="foo\file.txt" buildAction="EmbeddedResource" />
</contentFiles>

Nuget package does not restore all DLLs and Dependencies

I have created a Nuget package using Nuget Package Explorer. The package has some third party dlls that I use in my code. I dlls are included in the Nuget package and not referenced directly in the project references. The Nuget Package has the following.
- thirdPartyAAA.dll
- thirdPartyAAA.xml (Needed by thirdPartyAAA.dll)
- thirdPartyBBB.dll (needed by thirdPartyAAA.dll
- thirdPartyBBB.dll.config (used by thirdPartyBBB.dll)
- Dependency on HtmlAgilityPack nuget (Needed by thirdPartyAAA.dll)
- Dependency om RestSharp nuget (Needed by thirdPartyAAA.dll)
The problem is: when I reference this Nuget package in the code and compile the code I only get aaa.dll in the bin output folder. the following files are missing from the bin folder:
- thirdPartyAAA.xml
- thirdPartyBBB.dll
- thirdPartyBBB.dll.config
- All dlls from HtmlAgilityPack nuget
- All dll from RestSharp nuget
In my code I directly reference thirdPartyAAA.dll.
Is there a way - either during creating the Nuget Package or when referencing the package - to force the Nuget Package to restore all its contents and its dependencies? I need all the files that's included in the Nuget Package to be restored regardless if they are directly references in the code or not.
thank you all for your help.
Here is the manifest of the package if it helps.
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>MyPackage</id>
<version>1.0.0</version>
<title></title>
<authors>Dev</authors>
<owners>Dev</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>My package description.</description>
<dependencies>
<dependency id="HtmlAgilityPack" version="1.4.9" />
<dependency id="RestSharp" version="105.0.1" />
</dependencies>
</metadata>
<files>
<file src="content\thirdPartyAAA.chm" target="content\thirdPartyAAA.chm" />
<file src="content\thirdPartyAAA.XML" target="content\thirdPartyAAA.XML" />
<file src="content\thirdPartyBBB.dll.config" target="content\thirdPartyBBB.dll.config" />
<file src="lib\thirdPartyAAA.dll" target="lib\thirdPartyAAA.dll" />
<file src="lib\thirdPartyBBB.dll" target="lib\thirdPartyBBB.dll" />
</files>
</package>
The problem is: when I reference this Nuget package in the code and compile the code I only get aaa.dll in the bin output folder. the following files are missing from the bin folder:
- thirdPartyAAA.xml
- thirdPartyBBB.dll
- thirdPartyBBB.dll.config
- All dlls from HtmlAgilityPack nuget
- All dll from RestSharp nuget
First, for the thirdPartyBBB.dll, you should make sure the target framework version of project is higher than your dll's target framework. For example, If the target framework version of your project is .net 4.6.2, the target framework version of your thirdPartyBBB.dll should be lower than .net 4.6.2. Otherwise, you are referring a dll file with higher version target framework to the project with lower version target framework. This is incompatible.
Besides, for the dependencies of this package, you can check if those dependencies added to the project, and the properties Copy Local of those dlls are set to True. It works fine on my side.
Second, for the content file, you should add a .targets file in the build folder in your package with following code to copy those content files to the bin folder:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<None Include="$(ProjectDir)thirdPartyAAA.chm">
<Link>thirdPartyAAA.chm</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CustomToolNamespace></CustomToolNamespace>
</None>
<None Include="$(ProjectDir)thirdPartyAAA.XML">
<Link>thirdPartyAAA.XML</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CustomToolNamespace></CustomToolNamespace>
</None>
<None Include="$(ProjectDir)thirdPartyBBB.dll.config">
<Link>thirdPartyBBB.dll.config</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CustomToolNamespace></CustomToolNamespace>
</None>
</ItemGroup>
</Project>
For some details info, please check this thread.
Alternatively, you can use Install.ps1 file to change the property, the script looks like:
param($installPath, $toolsPath, $package, $project)
function MarkDirectoryAsCopyToOutputRecursive($item)
{
$item.ProjectItems | ForEach-Object { MarkFileASCopyToOutputDirectory($_) }
}
function MarkFileASCopyToOutputDirectory($item)
{
Try
{
Write-Host Try set $item.Name
$item.Properties.Item("CopyToOutputDirectory").Value = 2
}
Catch
{
Write-Host RecurseOn $item.Name
MarkDirectoryAsCopyToOutputRecursive($item)
}
}
#Now mark everything in the a directory as "Copy to newer"
MarkDirectoryAsCopyToOutputRecursive($project.ProjectItems.Item("TheFolderOfYourContentFiles"))
You can check similar issue for details.
In addition, I have created a test nuget package, you can check if it works for you, test it with .net framework project with target framework 4.6 and above.
https://1drv.ms/u/s!Ai1sp_yvodHf1QJriMiGQWdYveRm
Hope this helps.
Go to your solution explorer ,
on Ur project references,
right click on the DLL which is missing from the bin folder. Select properties, then make "copy local " to true. This will copy the DLL to the build path after compiling.
Go to your solution explorer ,
on Ur project references,
right click on the DLL which is missing from the bin folder. Select properties, then make "copy local " to true. This will copy the DLL to the build path after compiling.
For nuget restoring please refer the below link
https://learn.microsoft.com/en-us/nuget/consume-packages/package-restore-troubleshooting
I recently ran into almost exactly the same problem.
After 2 days, I discovered several posts that clarified that the contents folder are ONLY deployed during the +initial+ installation of the nuget.
What this means is that any files deployed as CONTENT are intended to be checked into your version control system, just like any other code in your project.
They are specifically NOT deployed when VS runs a "package restore" as it does when you build a project and some packages are missing.

NuGet Package fails to add reference to project for DLL inside lib directory

I'm attempting to package up a .NET DLL which references a C++ DLL. The nuspec file looks like this:
<?xml version="1.0"?>
<package >
<metadata>
<id>MyPackage</id>
<version>1.0.0</version>
<authors>some author</authors>
<owners>some owner</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>.NET Wrapper for rebuilt 64-bit version of MyPackage</description>
<copyright>Copyright 2014</copyright>
</metadata>
<files>
<file src="x64\MyPackage64.dll" target="content" />
<file src="MyPackageNET.dll" target="lib" />
</files>
</package>
When I examine the generated nupkg file, the internal file structure appears correct. The C++ DLL is in content and the .NET DLL is in the lib.
When I install the nupkg into a project, the content DLL is added to the project root and the lib DLL is added to the solution packages directory.
However, no reference is added to the project. I am forced to manually add the reference. I have tried adding the following node to metadata, to no avail:
<references>
<reference file="MyPackageNET.dll" />
</references>
Am I doing something wrong? I've generated other nuspec & nupkg files from varoius .csproj files, which properly add references to projects in which they've been installed. Is there something about the packaging of individual DLLs I've missed that is keeping a reference from being added to the project?
On a related note, if I cannot automatically add the reference, can anyone direct me to any resources which would explain the syntax of the $project.Object.Reference.Add method, or which would help me programmatically add a reference to the DLL to my project?
I experienced the same issue with additional symptoms of not being able to uninstall the package. I followed the guidance from Can't uninstall/reinstall NuGet package and added the packages.config file to the project. I had to copy the file from my solution folder as my project didn't have the file yet. Doing this corrected both symptoms.

Categories

Resources