2

I have created NuGet packages for .NET Standard class libraries, that is really easy with dotnet.exe. But it seems that dotnet pack doesn't work for plain old .csproj files targeting the full .NET Framework.

What is the preferred method to generate packages out of these kind of projects? With dotnet.exe? with nuget.exe? with msbuild?

I'm lost. It looks like package creation is a craft more like an automatic process! It's so confusing.

4
  • 7
    I'd personally try to convert the project to use an "SDK-style" project file (as per .NET Core) - that can still target .NET 4.7.2 and it's much simpler to work with. Commented Nov 13, 2019 at 15:10
  • The quick starts for NuGet seem to recommend using Visual Studio, but presumably you're wanting to automate the process? Commented Nov 13, 2019 at 15:14
  • @JonSkeet Is there a sample around? I've never targeted anything other that .NET Standards! Thanks in advance :) Commented Nov 13, 2019 at 15:35
  • 1
    @SuperJMN: It's exactly the same file format - just use <TargetFramework>net472</TargetFramework> Commented Nov 13, 2019 at 16:04

2 Answers 2

3

The preferred method to generate packages out of .Net Framework projects depends at least if the project is SDK-Style, or not.

Here we can find more details: https://learn.microsoft.com/en-us/nuget/resources/check-project-format

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

Comments

0

This worked for me (in Powershell):

cd "pathToProject"
& "C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\MSBuild.exe" -t:pack -p:"PackageOutputPath=myPackage;Authors=Me"

If you get weird build errors run "C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\MSBuild.exe" /t:restore first

I have this from here

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.