PublishSingleFile=true and PackAsTool=true in csproj do not play well with dotnet pack
See original GitHub issueSteps to reproduce
dotnet new console -n test -o .
- Add
<PackAsTool>true</PackAsTool>
and<PublishSingleFile>true</PublishSingleFile>
totest.csproj
dotnet pack
Expected behavior
As I understand it, .NET Core tool packages are RID-agnostic, so PublishSingleFile
should be ignored by dotnet pack
and only be observed by dotnet publish
. I am not sure what the behavior should be for PackAsTool=false
.
Actual behavior
$ dotnet publish -r linux-x64 # Works as expected.
Microsoft (R) Build Engine version 16.3.0-preview-19329-01+d31fdbf01 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Restore completed in 77.09 ms for /home/alexrp/tests/netcore/test.csproj.
You are using a preview version of .NET Core. See: https://aka.ms/dotnet-core-preview
test -> /home/alexrp/tests/netcore/bin/Debug/netcoreapp3.0/linux-x64/test.dll
test -> /home/alexrp/tests/netcore/bin/Debug/netcoreapp3.0/linux-x64/publish/
$ ls bin/Debug/netcoreapp3.0/linux-x64/publish
test test.pdb
$ dotnet pack # Fails unexpectedly.
Microsoft (R) Build Engine version 16.3.0-preview-19329-01+d31fdbf01 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Restore completed in 57.33 ms for /home/alexrp/tests/netcore/test.csproj.
/home/alexrp/.dotnet/sdk/3.0.100-preview7-012821/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.RuntimeIdentifierInference.targets(134,5): error NETSDK1097: It is not supported to publish an application to a single-file without specifying a RuntimeIdentifier. Please either specify a RuntimeIdentifier or set PublishSingleFile to false. [/home/alexrp/tests/netcore/test.csproj]
(Incidentally, passing --runtime linux-x64
to dotnet pack
makes no difference.)
Environment data
$ dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 3.0.100-preview7-012821
Commit: 6348f1068a
Runtime Environment:
OS Name: ubuntu
OS Version: 18.10
OS Platform: Linux
RID: ubuntu.18.10-x64
Base Path: /home/alexrp/.dotnet/sdk/3.0.100-preview7-012821/
Host (useful for support):
Version: 3.0.0-preview7-27912-14
Commit: 4da6ee6450
.NET Core SDKs installed:
2.1.604 [/home/alexrp/.dotnet/sdk]
2.2.204 [/home/alexrp/.dotnet/sdk]
3.0.100-preview6-012264 [/home/alexrp/.dotnet/sdk]
3.0.100-preview7-012821 [/home/alexrp/.dotnet/sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.11 [/home/alexrp/.dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.5 [/home/alexrp/.dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.11 [/home/alexrp/.dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.5 [/home/alexrp/.dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.0-preview6.19307.2 [/home/alexrp/.dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.0-preview7.19365.7 [/home/alexrp/.dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.11 [/home/alexrp/.dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.5 [/home/alexrp/.dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.0-preview6-27804-01 [/home/alexrp/.dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.0-preview7-27912-14 [/home/alexrp/.dotnet/shared/Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
dotnet pack creates package that is not compatible with . ...
I am packing this into a nuget package using dotnet pack command within VSTS, giving it the path to my .csproj file. I...
Read more >dotnet pack command - .NET CLI
The dotnet pack command builds the project and creates NuGet packages. The result of this command is a NuGet package (that is, a...
Read more >Bundling .NET build tools in NuGet
Figuring out how to glue these pieces together is the tricky bit, so in the sections below, I've created some instructions for how...
Read more >Building NuGet packages with Dotnet Core | by Xavier Penya
The package doesn't work if I have multiple projects. dotnet pack just packs a single project. It doesn't pack all of its project...
Read more >Exploring .NET Core's SourceLink - Stepping into the ...
I'll go over and start a new Console app that CONSUMES my NuGet library package. To make totally sure that I don't accidentally...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Well, I’m not saying they should necessarily be silently ignored. A simple warning would suffice, I’d think. There’s precedent for that too with e.g. the
ApplicationIcon
property:Alternatively, if there was a way to set these properties in the project file based on which publish command is being executed, that would be fine too.
In any case, I would have to say that, for me, the most surprising behavior here is the fact that these properties (whose names start with
Publish
) are being observed by thedotnet pack
command at all. From my perspective as a user, packing and publishing have nothing whatsoever to do with each other. This is further backed up by the existence of the distinctIsPackable
andIsPublishable
properties. It may be the case that they share some MSBuild logic under the hood, but I don’t think that’s obvious to a user at all unless they go digging through the MSBuild files and/or try these properties and discover that they apply todotnet pack
for some reason.