question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[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.

  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<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:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
jjpeppercommented, Feb 14, 2019

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

1reaction
nguerreracommented, Jul 12, 2018

Oh, and thanks @gitorrin for the report and @dasMulli for the investigation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[SDK 2.1.300] Command 'dotnet publish' fails for projects ...
Command 'dotnet publish' fails for projects publishing with GeneratePackageOnBuild=true. TargetFramework is netcoreapp2.0. ... This used to work ...
Read more >
dotnet publish fails intermittently because DLL is in use ...
I am working on an ASP.NET Core 3.1 web app project and I noticed that the one-click web deploy (for which I have...
Read more >
NETSDK1045: The current .NET SDK does not support ...
This error occurs when the build tools can't find the version of the .NET SDK that's needed to build a project. This is...
Read more >
dotnet publish command - .NET CLI
The dotnet publish command publishes a .NET project or solution to a directory.
Read more >
Self-contained deployment runtime roll forward
NET Core 2.1 SDK (version 2.1.300), a self-contained application deployment publishes the highest patch runtime on your machine.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found