dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.7k stars 1.06k forks source link

Ubuntu: dotnet workload install / restore work but nothing is added to the target file #36043

Open aboimpinto opened 1 year ago

aboimpinto commented 1 year ago

Describe the bug

I don't understand why, after installing the "android" workload, the app still says it is not installed. This may not be a bug, but I may be doing something wrong and need help figuring it out. Avalonia should be fine (there is always the possibility) because the dotnet cannot find the workload. Thanks

To Reproduce

  1. Create an Avalonia XPlat project
  2. Build the Android app
  3. Error message: /usr/lib/dotnet/sdk/7.0.112/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.ImportWorkloads.targets(38,5): error NETSDK1147: To build this project, the following workloads must be installed: android [/home/esqueleto/myWork/AvaloniaMobileTestBed/AvaloniaMobileTestBed.Android/AvaloniaMobileTestBed.Android.csproj]
  4. Install the workload using the command: dotnet workload install android
  5. Got the successful message: Successfully installed workload(s) android wasm-tools maui-android.
  6. build again
  7. got the same error message error /usr/lib/dotnet/sdk/7.0.112/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.ImportWorkloads.targets(38,5): error NETSDK1147: To build this project, the following workloads must be installed: android [/home/esqueleto/myWork/AvaloniaMobileTestBed/AvaloniaMobileTestBed.Android/AvaloniaMobileTestBed.Android.csproj]

Exceptions (if any)

none

Further technical details

$ dotnet --info .NET SDK: Version: 7.0.112 Commit: c972157895

Runtime Environment: OS Name: ubuntu OS Version: 23.04 OS Platform: Linux RID: ubuntu.23.04-x64 Base Path: /usr/lib/dotnet/sdk/7.0.112/

Host: Version: 7.0.12 Architecture: x64 Commit: 4a824ef37c

.NET SDKs installed: 7.0.112 [/usr/lib/dotnet/sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 7.0.12 [/usr/lib/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 7.0.12 [/usr/lib/dotnet/shared/Microsoft.NETCore.App]

Other architectures found: None

Environment variables: Not set

global.json file: Not found

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

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

GuoMonth commented 1 year ago

I have the similar error.

I am successfully installed workload wasm-tools by dotnet workload install wasm-tools

in my local macos compile success, but when i am compile in devops machine(Ubuntu), get a error:

Starting: dotnet build Release
==============================================================================
Task         : Command line
Description  : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
Version      : 2.229.0
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
==============================================================================
Generating script.
Script contents:
dotnet build src/xxxxx.sln --configuration Release
========================== Starting Command Output ===========================
/usr/bin/bash --noprofile --norc /home/agent/vsagent3.224.1/_work/_temp/3300ee98-ca68-4dcd-b335-af52d4bfa303.sh
MSBuild version 17.4.8+6918b863a for .NET
  Determining projects to restore...
/usr/lib/dotnet/sdk/7.0.112/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.ImportWorkloads.targets(38,5): error NETSDK1147: To build this project, the following workloads must be installed: wasm-tools [/home/agent/vsagent3.224.1/_work/2/s/src/xxxxx.csproj]
/usr/lib/dotnet/sdk/7.0.112/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.ImportWorkloads.targets(38,5): error NETSDK1147: To install these workloads, run the following command: dotnet workload restore [/home/agent/vsagent3.224.1/_work/2/s/src/xxxxx.csproj]

Build FAILED.

/usr/lib/dotnet/sdk/7.0.112/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.ImportWorkloads.targets(38,5): error NETSDK1147: To build this project, the following workloads must be installed: wasm-tools [/home/agent/vsagent3.224.1/_work/2/s/src/xxxxx.csproj]
/usr/lib/dotnet/sdk/7.0.112/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.ImportWorkloads.targets(38,5): error NETSDK1147: To install these workloads, run the following command: dotnet workload restore [/home/agent/vsagent3.224.1/_work/2/s/src/xxxxx.csproj]
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:00.56

Workload updates are available. Run `dotnet workload list` for more information.
##[error]Bash exited with code '1'.
Finishing: dotnet build Release
GuoMonth commented 1 year ago

I am try dotnet workload restore doc and it run successfully, then run dotnet build Release still get same error. đź’”

Starting: dotnet workload restore
==============================================================================
Task         : Command line
Description  : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
Version      : 2.229.0
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
==============================================================================
Generating script.
Script contents:
dotnet workload restore src/xxxxx.sln
========================== Starting Command Output ===========================
/usr/bin/bash --noprofile --norc /home/agent/vsagent3.224.1/_work/_temp/ac236cff-a312-495f-b00d-53f6ef6127a2.sh
Installing workloads: wasm-tools

Workload(s) 'wasm-tools' are already installed.
GuoMonth commented 1 year ago

when I am change devops machine , compile success!

pool:
  name: my-ubuntu
....
.....

update to:

trigger: none

pool:
  vmImage: "ubuntu-latest"

variables:
  solution: "**/*.sln"
  buildPlatform: "Any CPU"
  buildConfiguration: "Release"

steps:
  - script: dotnet workload restore src/xxxxx.sln
    displayName: "dotnet workload restore"
  - script: dotnet build src/xxxxx.sln --configuration $(buildConfiguration)
    displayName: "dotnet build $(buildConfiguration)"

reason guess: maybe my-ubuntu dotnet version not match the workload.

liui commented 1 year ago

Try rolling back dotnet sdk version to 7.0.100