My nuget package has dll:s for different .Net framework versions. One for CLR2 and one for CLR4.
net20/mylibrary.dll
net40/mylibrary.dll
This works fine when I use a package in e.g. .Net 3.5 and .Net 4 projects.
Sometimes I have projects which work with both .Net 3.5 and .Net 4. This is handled via 2 project configurations. In one case I build the .Net 4 version from the "Debug" configuration and the .Net 3.5 version from the "Release" configuration. Both of the configurations need to use net20
references.
My csproj file looks like this:
<PropertyGroup>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
...
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
...
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
...
</PropertyGroup>
nuget will always install the net40
assemblies which break the "Release" build.
Currently I manually change net40
to net20
in the .csproj file after install/update. Is there a way to avoid the edit?
Create a separate project for .net 4 and link the files into it.