A year or so ago, @mm6502 opened a bug report detailing how nuget pack would look in the wrong location for the build files when packing a multi-targeted project, resulting in an error similar to:
Error NU5012: Unable to find 'bin\release\{Project}\bin\release\'. Make sure the project has been built.
If you are going through the NuGet Pack task on Azure DevOps, the error will be wrapped as follows (related report):
[error]The nuget command failed with exit code(1) and error(Unable to find 'bin\release\{Project}\bin\release\'. Make sure the project has been built.)
This issue was closed since a workaround was provided. The workaround, however, is insufficient for the reasons detailed below; this should instead be reopened and treated as a bug.
The workaround suggested was to use msbuild /t:pack instead. This is insufficient because:
nuget will work the same on multi-target projects as it does on single-target projects.msbuild is not a comparable substitute, as it doesn't permit e.g. disabling the build, or specifying a version number (without extra tooling). It's also not the recommended approach for Azure DevOps.netstandard2.0.csproj file to add target framework net4:<TargetFrameworks>net4;netstandard2.0</TargetFrameworks>msbuild (to check the build passes and package is created):nuget restoremsbuild Test.csproj /t:Clean,Build,Pack /p:Configuration=Releasenuget:nuget pack Test.csproj -Build -p Configuration=ReleaseNuGet Version: 4.9.2.5706
Attempting to build package from 'Test.csproj'.
MSBuild auto-detection: using msbuild version '15.9.21.664' from 'C:\Apps\Development\IDEs\Visual Studio 2017\MSBuild\15.0\bin'. Use option -MSBuildVersion to force nuget to use a specific version of MSBuild.
Error NU5012: Unable to find 'bin\release\Test\bin\release\'. Make sure the project has been built.
NuGet.Packaging.Core.PackagingException: Unable to find 'bin\release\Test\bin\release\'. Make sure the project has been built.
at NuGet.CommandLine.ProjectFactory.BuildProject()
at NuGet.CommandLine.ProjectFactory.CreateBuilder(String basePath, NuGetVersion version, String suffix, Boolean buildIfNeeded, PackageBuilder builder)
at NuGet.Commands.PackCommandRunner.BuildFromProjectFile(String path)
at NuGet.Commands.PackCommandRunner.BuildPackage()
at NuGet.CommandLine.PackCommand.ExecuteCommand()
at NuGet.CommandLine.Command.ExecuteCommandAsync()
at NuGet.CommandLine.Command.Execute()
at NuGet.CommandLine.Program.MainCore(String workingDirectory, String[] args)
See @mm6502's original bug report for a sample project.
Thanks for opening this issue. It's something that should be fixed.
@JeremyCaney
I believe that you may be some confusion about the resolution of that issue.
NuGet ships 2 implementations of pack.
The nuget.exe one, the primitive nuspec based pack, and the https://www.nuget.org/packages/NuGet.Build.Tasks.Pack/ or what's basically shipped with dotnet.exe.
The tooling for SDK based projects is dotnet.exe/targets pack.
The gap in question is the following issue https://github.com/NuGet/Home/issues/4491.
It's not about single vs multi tfm projects.
It's about nuget.exe and SDK based projects nuspecless.
Based on my above comments I'd like to dup this issue to https://github.com/NuGet/Home/issues/4491.
Closing per my above comment.
@JeremyCaney
I believe that you may be some confusion about the resolution of that issue.
NuGet ships 2 implementations of pack.
The nuget.exe one, the primitive nuspec based pack, and the https://www.nuget.org/packages/NuGet.Build.Tasks.Pack/ or what's basically shipped with dotnet.exe.The tooling for SDK based projects is dotnet.exe/targets pack.
The gap in question is the following issue #4491.
It's not about single vs multi tfm projects.
It's about nuget.exe and SDK based projects nuspec_less_.Based on my above comments I'd like to dup this issue to #4491.
I used dotnet pack and got my project packed up with multiple platforms. Nuget pack did not work.
How does one then change the Package Versioning, since Nuget Pack is not an option for multi-Targeting?
As @Njoro007 said, this is an issue for packages with versions derived from pipeline variables in, e.g., Azure DevOps.
Most helpful comment
How does one then change the Package Versioning, since Nuget Pack is not an option for multi-Targeting?