Specifying framework version of dependency manually in SDK style project
I am updating an old project to the SDK style and I have a reference that looked like
After moving to SDK style I had
Which caused the build system to select the net46 version of the package not the net45 which turns out to be important. How can I override that behavior? Going back to the <Reference seems to work but it'd be nice to use PackageReference if possible.
6 Replies
You'll need a combo of
PackageRef
with ExcludeAssets="all"
and GeneratePathProperty="true"
, then a Reference
element pointing at <package path>\lib\net45\package.dll
NuGet PackageReference in project files
Details on NuGet PackageReference in project files as supported by NuGet 4.0+ and VS2017 and .NET Core 2.0
Which, IMO, is better than just a raw
Reference
Okay so what that gets me is that the version isn't hardcoded in my reference anymore correct?
So it can be found by dotnet build and such. Easily restored globally etc.
Correct
The SDK generates where the package path is, so you no longer need to care if it's at EnlistmentRoot,
~/.nuget
, or wherever else
You only need to care about the path within the packageOkay that sounds like a reasonable compromise to me, thanks!
Right now we've got a single packages.config and 100% hardcoded <References so it'll be nice to let that go