Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Targeting Specific Framework for NuGet Package in .nuspec

Tags:

nuget

nuspec

Is there a way to pack and push a NuGet package to a specific framework, in my case it being net35?

I want to push a package so when other's install it, it will show as targetFramework="net35" in their packages.config.

Can I specify this in the .nuspec?

like image 414
Corghee Avatar asked Oct 30 '22 10:10

Corghee


1 Answers

You can create a NuGet package so that your assembly is in a lib\net35 folder. However the value that gets added to the packages.config file is the target framework of the project not the assembly used from the NuGet package.

To target .NET 3.5 in your NuGet package your .nuspec file would have something similar to:

<files>
    <file src="bin\**" target="lib\net35" />
</files>

If you are using nuget pack YourProject.csproj then instead of specifying the assemblies in your .nuspec file you should instead change your project to target .NET 3.5. Then nuget pack should create the correct lib\net35 directory.

like image 148
Matt Ward Avatar answered Jan 02 '23 20:01

Matt Ward