Setting up a common nuget packages folder for all solutions when some projects are included in multiple solutions

I have a similar situation with external and internal package sources with projects referenced in more than one solution. I just got this working with one of our code bases today and it seems to be working with the developer workstations and our build server. The below process has this scenario in mind (although it … Read more

NuGet behind a proxy

Here’s what I did to get this working with my corporate proxy that uses NTLM authentication. I downloaded NuGet.exe and then ran the following commands (which I found in the comments to this discussion on CodePlex): nuget.exe config -set http_proxy=http://my.proxy.address:port nuget.exe config -set http_proxy.user=mydomain\myUserName nuget.exe config -set http_proxy.password=mySuperSecretPassword This put the following in my NuGet.config … Read more

How do I enable NuGet Package Restore in Visual Studio?

It took far too long but I finally found this document on Migrating MSBuild-Integrated solutions to Automatic Package Restore and I was able to resolve the issue using the methods described here. Remove the ‘.nuget’ solution directory along from the solution Remove all references to nuget.targets from your .csproj or .vbproj files. Though not officially … Read more

Create nuget package from dlls

I want to create a nuget package which adds multiple .dll as references to my project. I would like give you two solutions to achieve this: First, Use NuGet Package Explorer: Download the NuGet Package Explorer. Open the NuGet Package Explorer, select the create a new package. Add a lib folder on the content tab, … Read more

Add native files from NuGet package to project output directory

Using the Copy target in the targets file to copy required libraries won’t copy those files to other projects which reference the project, resulting in a DllNotFoundException. This can be done with a much simpler targets file though, using a None element, as MSBuild will copy all None files to referencing projects. <Project xmlns=”http://schemas.microsoft.com/developer/msbuild/2003″> <ItemGroup> … Read more

Set content files to “copy local : always” in a nuget package

Instead of using a PowerShell script another approach is to use an MSBuild targets or props file with the same name as the package id: <Project xmlns=”http://schemas.microsoft.com/developer/msbuild/2003″> <ItemGroup> <None Include=”$(MSBuildThisFileDirectory)importantfile.xml”> <Link>importantfile.xml</Link> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </None> </ItemGroup> </Project> In the nuspec file then, instead of adding the required files to the Content directory, add them to the Build … Read more

How do I get .NET Core projects to copy NuGet references to the build output?

You can add this to a <PropertyGroup> inside your csproj file to enforce copying NuGet assemblies to the build output: <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> However, note that the build output (bin/Release/netcoreapp*/*) is not supposed to be portable and distributable, the output of dotnet publish is. But in your case, copying the assemblies to the build output is probably … Read more