[SDK 2.1.300] Command 'dotnet publish' fails for projects with GeneratePackageOnBuild=true
See original GitHub issue@gitorrin commented on Thu Jul 12 2018
Command ‘dotnet publish’ fails for projects publishing with GeneratePackageOnBuild=true. TargetFramework is netcoreapp2.0.
<PropertyGroup> <TargetFramework>netcoreapp2.0</TargetFramework> <GeneratePackageOnBuild>true</GeneratePackageOnBuild> </PropertyGroup>
This used to work with the previous SDK version 2.1.101. The error it generates is: "C:\Program Files\dotnet\sdk\2.1.300\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(168,5): error MSB3030: Could not copy the file “obj\Debug\netcoreapp2.0<anyAssemblyName>.dll” because it was not found. "
@dasMulli commented on Thu Jul 12 2018
Do you have ay steps to reproduce? what project type is affected? I couldn’t reproduce with a couple of configurations I thought you could have.
@gitorrin commented on Thu Jul 12 2018
Sorry, apparently I haven’t added enough details. Thank you for reacting so fast.
- Open Command Prompt
- run dotnet new classlib
- Edit project file to have GeneratePackageOnBuild set to true & target net core 2.0
Project file should look like this:
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>netcoreapp2.0</TargetFramework> <GeneratePackageOnBuild>true</GeneratePackageOnBuild> </PropertyGroup> </Project>
- (optional)
Add global.json to project folder with content
{ "sdk": { "version": "2.1.300" } }
- run dotnet publish
Fails with error
C:\Program C:\Program Files\dotnet\sdk\2.1.300\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(168,5): error MSB3030: Could not copy the file “obj\Debug\netstandard2.0\test1.dll” because it was not found. [C:\Users<user>\Documents\Visual Studio 2017\Projects\test1\test1.csproj]
PS: modifying the global.json file to
{ "sdk": { "version": "2.1.101" } }
and running dotnet publish succeeds
@dasMulli commented on Thu Jul 12 2018
Thanks, can repro now. the important part to the repro is that no dotnet build
etc. have been called before.
@dasMulli commented on Thu Jul 12 2018
@nguerrera the problem here is that the new --no-build
option for publish is interfering with the existing NuGet logic for GeneratePackageOnBuild
which has logic to not trigger a build again while packing.
In essence, both pieces of logic use $(NoBuild)
for this 😱
Is it still possible to rename publish’s NoBuild
to NoBuildOnPublish
or something similar?
@dasMulli commented on Thu Jul 12 2018
@gitorrin you are right, this is a regression in 2.1.3xx. The workaround is to explicitly build (dotnet build
) before publishing.
@gitorrin commented on Thu Jul 12 2018
Thanks for looking into this, @dasMulli.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:9 (6 by maintainers)
Top GitHub Comments
@nguerrera can you explain why this was moved to closed? We are seeing the problem in dotnet v2.1.500 downloaded today. Is it meant to be fixed already?
Oh, and thanks @gitorrin for the report and @dasMulli for the investigation.