2

hi i want create multi target nuget package. Everything seems to work well Except that whene i create wpf NetCore3 app and install my package The .NET Framework dll is used and The NetCore3 library is not used

<files>
    <file src="lib\netcore\Control.dll" target="lib\netcore" />
    <file src="lib\net48\Control.dll" target="lib\net48" />
    <file src="lib\net40\Control.dll" target="lib\net40" />
    <file src="lib\net40\Microsoft.Windows.Shell.dll" target="lib\net40" />
  </files>

Is this lib\netcore correct?

2 Answers 2

1

You should use the same TFM in the package as your csproj has in the <TargetFramework> element. If your csproj has <TargetFramework>netcore</TargetFramework>, then sure, use lib/netcore/whatever.dll. But if your csproj has <TargetFramework>netcoreapp3.0</TargetFramework>, then you should use lib/netcoreapp3.0/whatever.dll.

However, SDK style projects, the only type that work with .NET Core 3.0, support multi-targeting (change <TargetFramework> to <TargetFrameworks>, then use a semicolon delimited list netcoreapp3.0;net48;net40), and NuGet's pack targets know how to pack these projects automatically. So there is no need to create a nuspec yourself, which minimises the risk of making these types of mistakes.

So, just as NuGet's docs on creating multi-targeting packages says, just use dotnet pack to create your package, and let NuGet figure out what lib/* folders to use. Avoid using nuspec files. Any other metadata you specify in the nuspec can specified via MSBuild properties in your csproj.

Sign up to request clarification or add additional context in comments.

Comments

0

netcore is a Microsoft Store TFM.

For your .NET Core 3 (netcoreapp3.0) WPF app, you'd need to multi-target with netstandard or netcoreapp in your NuGet package.

For example:

<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.