In Visual Studio 2017 using the new .csproj
format, the NuGet dependencies are automatically copied into the NuGet package based on the .csproj
file's PackageReference
s.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard1.3;net45</TargetFrameworks>
<DefineConstants Condition=" '$(TargetFramework)' == 'netstandard1.3' ">$(DefineConstants);LIBLOG_PORTABLE</DefineConstants>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
<!-- /* Package references for .NET Standard 1.3 */ -->
<PackageReference Include="Microsoft.CSharp" Version="4.4.0" />
<PackageReference Include="System.IO.MemoryMappedFiles" Version="4.3.0" />
<PackageReference Include="System.Resources.ResourceManager" Version="4.3.0" />
<PackageReference Include="System.Reflection.TypeExtensions" Version="4.4.0" />
<PackageReference Include="System.Runtime" Version="4.3.0" />
<PackageReference Include="System.Threading.Thread" Version="4.3.0" />
</ItemGroup>
</Project>
So the only thing extra you need to do is add those dependencies from NuGet to your project. This can be done either by
- Manually editing the project file (Right-click the project in Solution Explorer and choose
Edit <projectName>.csproj
)
- Installing the NuGet package via NuGet Package Manager
Changing Dependencies by Updating a .nupkg
File
Alternatively, since a .nupkg
file is just a .zip
file with a different extension, you can change its contents:
- Unzip it with a standard zip utility to a temporary directory
- In the temporary directory, modify the contents of its
.nuspec
file, adding additional dependencies as appropriate
- Zip the contents of the temporary directory again
- Rename the new
.zip
file, giving it the extension .nupkg