Skip to content
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

CLI - dotnet workload restore fails on solution if there is a .dcproj for Docker #42394

Closed
pomianowski opened this issue Jul 26, 2024 · 4 comments · Fixed by #42467
Closed

CLI - dotnet workload restore fails on solution if there is a .dcproj for Docker #42394

pomianowski opened this issue Jul 26, 2024 · 4 comments · Fixed by #42467

Comments

@pomianowski
Copy link

Describe the bug

When attempting to restore workloads for the solution using the command dotnet workload restore .\MySolution.sln, the build fails with an error related to the docker-compose.dcproj project file.

To Reproduce

Steps to reproduce the behavior:

Open a command line interface.
Navigate to the directory containing the solution file with .NET Aspire AppHost and Docker compose projects.
Run the command: dotnet workload restore .\MySolution.sln.
Observe the error.

Exceptions (if any)

Project "C:\some-path\docker-compose.dcproj" (_GetRequiredWorkloads target(s)):

C:\some-path\docker-compose.dcproj : error MSB4057: The target "_GetRequiredWorkloads" does not exist in the project.
Done building project "docker-compose.dcproj" -- FAILED.
Failed to restore workload for project C:\some-path\docker-compose.dcproj: Failed to run MSBuild Target _GetRequiredWorkloads.

Further technical details

  • Include the output of dotnet --info
  • The IDE (VS / VS Code/ VS4Mac) you're running on, and its version
.NET SDK:
 Version:           8.0.303
 Commit:            29ab8e3268
 Workload version:  8.0.300-manifests.d7126b9e
 MSBuild version:   17.10.4+10fbfbf2e

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22631
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\8.0.303\
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Workloads untriaged Request triage from a team member labels Jul 26, 2024
@pomianowski pomianowski changed the title dotnet workload restore fails on solution if there is a .dcproj for Docker CLI - dotnet workload restore fails on solution if there is a .dcproj for Docker Jul 26, 2024
@Jonas-Marty
Copy link

I got the same problem and also have a docker compose project in my solution
image

I even get the problem when i specify the project directly:
image

dotnet --info
.NET SDK:
Version: 8.0.400-preview.0.24324.5
Commit: 736a2616db
Workload version: 8.0.400-manifests.d7126b9e
MSBuild version: 17.11.0+1192b22fd

Runtime Environment:
OS Name: Windows
OS Version: 10.0.22631
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\8.0.400-preview.0.24324.5\

.NET workloads installed:
Configured to use loose manifests when installing new manifests.
[android]
Installation Source: SDK 8.0.400-preview.0, VS 17.10.35027.167
Manifest Version: 34.0.113/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.android\34.0.113\WorkloadManifest.json
Install Type: FileBased

[aspire]
Installation Source: SDK 8.0.400-preview.0, VS 17.10.35027.167, VS 17.11.35103.136
Manifest Version: 8.1.0/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.aspire\8.1.0\WorkloadManifest.json
Install Type: FileBased

[ios]
Installation Source: SDK 8.0.400-preview.0, VS 17.10.35027.167
Manifest Version: 17.2.8078/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.ios\17.2.8078\WorkloadManifest.json
Install Type: FileBased

[maccatalyst]
Installation Source: SDK 8.0.400-preview.0, VS 17.10.35027.167
Manifest Version: 17.2.8078/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.maccatalyst\17.2.8078\WorkloadManifest.json
Install Type: FileBased

[maui]
Installation Source: SDK 8.0.400-preview.0
Manifest Version: 8.0.61/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.maui\8.0.61\WorkloadManifest.json
Install Type: FileBased

[maui-windows]
Installation Source: SDK 8.0.400-preview.0, VS 17.10.35027.167, VS 17.11.35103.136
Manifest Version: 8.0.61/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.maui\8.0.61\WorkloadManifest.json
Install Type: FileBased

[wasm-tools]
Installation Source: SDK 8.0.400-preview.0, VS 17.10.35027.167
Manifest Version: 8.0.7/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.workload.mono.toolchain.current\8.0.7\WorkloadManifest.json
Install Type: FileBased

[wasm-tools-net6]
Installation Source: SDK 8.0.400-preview.0, VS 17.10.35027.167, VS 17.11.35103.136
Manifest Version: 8.0.7/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.workload.mono.toolchain.net6\8.0.7\WorkloadManifest.json
Install Type: FileBased

[wasm-tools-net7]
Installation Source: SDK 8.0.400-preview.0, VS 17.10.35027.167, VS 17.11.35103.136
Manifest Version: 8.0.7/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.workload.mono.toolchain.net7\8.0.7\WorkloadManifest.json
Install Type: FileBased

Host:
Version: 8.0.7
Architecture: x64
Commit: 2aade6beb0

.NET SDKs installed:
6.0.424 [C:\Program Files\dotnet\sdk]
7.0.410 [C:\Program Files\dotnet\sdk]
8.0.303 [C:\Program Files\dotnet\sdk]
8.0.400-preview.0.24324.5 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.32 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.19 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.19 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.30 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.19 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
Not set

global.json file:
Not found

Learn more:
https://aka.ms/dotnet/info

Download .NET:
https://aka.ms/dotnet/download

@baronfel baronfel added the needs team triage Requires a full team discussion label Jul 29, 2024
@baronfel
Copy link
Member

Triage Notes

workload restore performs a build of the _GetRequiredWorkloads Target for all projects built - including parsing the solution and getting all projects from that if required. This is not ideal - we should really only be calling this target on projects that have imported the Microsoft.NET.Sdk. We should possibly filter based on some MSBuild Property or ProjectCapability Item that signals workloads support in a project.

The target exists in two places:

The cross-targeting targets are imported by the Microsoft.NET.Sdk.BeforeCommonCrossTargeting.targets for multi-TFM projects, and by the MIcrosoft.NET.Sdk.BeforeCommon.targets for single-targeted projects.

Proposed resolution

  • Add a new ProjectCapability like <ProjectCapability Include="NetSDKWorkloadsSupported" /> to the two targets that define the _GetRequiredWorkloads Target so that it's available during MSBuild evaluation
  • Update the workload restore code to filter the set of projects to call the _GetRequiredWorkloads Target on to those that contain the NETSdkWorkloadsSupported ProjectCapability Item

Temporary workaround

@pomianowski and @Jonas-Marty - you may be able to work around this problem by adding a dummy Target to your dcproj (and any other unsupported project types). This Target doesn't need to do any logic, it can be as simple as adding this to each project:

<Target Name="_GetRequiredWorkloads" />

@marcpopMSFT
Copy link
Member

Triage: SkipNonexistentTargets might be an alternative way to implement this.

@marcpopMSFT marcpopMSFT added this to the 9.0.1xx milestone Jul 30, 2024
@marcpopMSFT marcpopMSFT removed untriaged Request triage from a team member needs team triage Requires a full team discussion labels Jul 30, 2024
@baronfel
Copy link
Member

There's not an API-based version of 'SkipNonexistentTargets' like there is for the MSBuild intrinsic Task, so we just have to check if the target exists in the ProjectInstance. This is easy to do, so I sent a PR.

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

Successfully merging a pull request may close this issue.

4 participants