Skip to content

dotnet clean requires a RID if SelfContained=true in project file but no RID is set #27488

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

Closed
jtschuster opened this issue Aug 26, 2022 · 7 comments
Assignees

Comments

@jtschuster
Copy link
Member

jtschuster commented Aug 26, 2022

Describe the bug

Running dotnet clean with true in the project file will fail and return an error.

error NETSDK1031: It is not supported to build or publish a self-contained application without specifying a RuntimeIdentifier. You must either specify a RuntimeIdentifier or set SelfContained to false.

It doesn't seem like it should be necessary to set a RID for dotnet clean.

To Reproduce

Create a project file with SelfContained

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <SelfContained>true</SelfContained>
  </PropertyGroup>
</Project>

Run dotnet clean.

Further technical details

dotnet --info:
.NET SDK:
Version: 7.0.100-rc.2.22417.1
Commit: f3da421

Runtime Environment:
OS Name: Windows
OS Version: 10.0.22000
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\7.0.100-rc.2.22417.1\

Host:
Version: 7.0.0-rc.1.22411.12
Architecture: x64
Commit: f52d8c59bb

.NET SDKs installed:
3.1.422 [C:\Program Files\dotnet\sdk]
6.0.400 [C:\Program Files\dotnet\sdk]
7.0.100-rc.2.22417.1 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 3.1.28 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.0-rc.1.22415.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.28 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.0-rc.1.22411.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.28 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.0-rc.1.22379.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
x86 [C:\Program Files (x86)\dotnet]

Environment variables:
Not set

global.json file:
Not found

@ghost ghost added the untriaged Request triage from a team member label Aug 26, 2022
@ghost
Copy link

ghost commented Aug 26, 2022

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@nagilson
Copy link
Member

Not surprised this happens, though this is an interesting scenario. Thanks for reporting it @jtschuster. Verified that this is fixed already by #26143 for rc-2. Except, we will be making clean rid-specific here. Going to ask if we care about that or not, I don't think we do.

@nagilson nagilson added needs team triage Requires a full team discussion and removed untriaged Request triage from a team member labels Sep 14, 2022
@marcpopMSFT marcpopMSFT added Area-NetSDK and removed needs team triage Requires a full team discussion labels Sep 14, 2022
@marcpopMSFT
Copy link
Member

If folks want a dotnet clean --all, we should track as a separate issue and come up with a design as that's not as easy as it sounds.

@baronfel
Copy link
Member

Would appreciate any feedback on dotnet clean --all here: #22692

@rkm
Copy link

rkm commented Nov 20, 2024

Just stumbled onto this same issue. Could the solution be as simple as adding the --use-current-runtime option to dotnet clean like we have for the other commands?

@baronfel
Copy link
Member

@rkm it doesn't look like clean supports --use-current-runtime:

command.Options.Add(FrameworkOption);
command.Options.Add(CommonOptions.RuntimeOption.WithHelpDescription(command, LocalizableStrings.RuntimeOptionDescription));
command.Options.Add(ConfigurationOption);
command.Options.Add(CommonOptions.InteractiveMsBuildForwardOption);
command.Options.Add(CommonOptions.VerbosityOption);
command.Options.Add(OutputOption);
command.Options.Add(CommonOptions.ArtifactsPathOption);
command.Options.Add(NoLogoOption);
command.Options.Add(CommonOptions.DisableBuildServersOption);

We'd need to add command.Options.Add(CommonOptions.CurrentRuntimeOption(LocalizableStrings.CmdCurrentRuntimeOptionDescription)) to this list to enable it - would you be interested in sending that PR?

@rkm
Copy link

rkm commented Nov 20, 2024

Definitely! I will send a PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants