Core: [SDK 2.1.300] Command 'dotnet publish' fails for projects with GeneratePackageOnBuild=true

Created on 12 Jul 2018  路  7Comments  路  Source: dotnet/core

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\.dll" because it was not found. "

Most helpful comment

@gitorrin you are right, this is a regression in 2.1.3xx. The workaround is to explicitly build (dotnet build) before publishing.

All 7 comments

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.

Sorry, apparently I haven't added enough details. Thank you for reacting so fast.

  1. Open Command Prompt
  2. run dotnet new classlib
  3. 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>

  1. (optional)
    Add global.json to project folder with content
    { "sdk": { "version": "2.1.300" } }
  2. 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\\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

Thanks, can repro now. the important part to the repro is that no dotnet build etc. have been called before.

@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?

@gitorrin you are right, this is a regression in 2.1.3xx. The workaround is to explicitly build (dotnet build) before publishing.

Thanks for looking into this, @dasMulli.

Issue moved to dotnet/cli #9656 via ZenHub

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shanselman picture shanselman  路  3Comments

lesomnus picture lesomnus  路  3Comments

rykr picture rykr  路  3Comments

ugurcemozturk picture ugurcemozturk  路  3Comments

ffes picture ffes  路  3Comments