-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PublishSingleFile=true and PackAsTool=true in csproj do not play well with dotnet pack #10402
Comments
On a perhaps related note, if you replace the $ dotnet pack
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 16.17 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/test.dll
test -> /home/alexrp/tests/netcore/bin/Debug/netcoreapp3.0/test.dll
/home/alexrp/.dotnet/sdk/3.0.100-preview7-012821/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.ILLink.targets(113,5): error NETSDK1102: Optimizing assemblies for size is not supported for the selected publish configuration. Please ensure that you are publishing a self-contained app. [/home/alexrp/tests/netcore/test.csproj] Again, it seems like |
I am not sure silently ignoring an option is the right choice here, as it will cause confusion when the thing the user wanted to happen does not happen. The issue here is that trimming is only supported for self-contained apps while packastool is support for framework dependent apps. If you are trying to use packastool, I would say for you to follow the error message recommendation and remove trimming or turn it off. |
That's the thing though, I don't want trimming or self-contained packaging to happen when doing Of course, I could just remove IMO, the obvious command the user is going to type should do the obvious and supported thing for the project. |
But the issue is that a user specifying these properties and then running pack might spec that these properties will work for pack, unless something happens, which is what we are doing. This is the last surprising behavior: I set some configuration, if it does not work with the command I am running, tell me, don't silently ignore said configurations and let me scratching my head to understand which ones are honored by which commands. |
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
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 |
I have also been bitten by this I though that PublishSingleFile, PublishTrimmed and PublishReadyToRun would only effect the dotnet publish command otherwise I would have expected them to be called just SingleFile, Trimmed and ReadyToRun... I think this behavior is more unexpected than expected. |
I keep running into this, even 2 years later. My options seem to be:
Both of these options are really quite bad. Is there any interest in addressing this at all? |
As a workaround trick, it seems that there are some "private" properties |
Steps to reproduce
dotnet new console -n test -o .
<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 bydotnet pack
and only be observed bydotnet publish
. I am not sure what the behavior should be forPackAsTool=false
.Actual behavior
(Incidentally, passing
--runtime linux-x64
todotnet pack
makes no difference.)Environment data
The text was updated successfully, but these errors were encountered: