51工具盒子

依楼听风雨
笑看云卷云舒,淡观潮起潮落

Azure Pipelines: 错误 NETSDK1139: 未识别目标平台标识符 android

英文:

Azure Pipelines: Error NETSDK1139: The target platform identifier android was not recognized

问题 {#heading}

我有一个.NET MAUI移动应用程序项目,自昨天以来,它在Azure DevOps中构建正常,直到昨天。

然后我开始遇到这个错误:

错误 NETSDK1139:未识别目标平台标识符android

我在我的csproj文件中指定了目标平台为net7.0-android

<TargetFrameworks>net7.0-android;net7.0-ios</TargetFrameworks>

在执行这个任务后

- task: NuGetCommand@2
  displayName: "执行NuGet还原"
  inputs:          
    command: restore
    VstsFeed: "xxx.xxxx/Lib"

Nuget还原在执行正常的dotnet restore之后被调用。

- task: NuGetAuthenticate@0
  displayName: "NuGet身份验证"

- task: DotNetCoreCLI@2
  displayName: "执行DotNet还原"
  inputs:
    command: restore
    feedsToUse: 'select'
    VstsFeed: "xxx.xxxx/Lib"

- task: NuGetCommand@2
  displayName: "执行NuGet还原"
  inputs:          
    command: restore
    VstsFeed: "xxx.xxxx/Lib"

我想Windows代理映像现在缺少一些工作负载。

我使用以下命令安装工作负载:

- task: Bash@3
  displayName: "安装MAUI支持"
  inputs:
    targetType: 'inline'
    script: |
      dotnet nuget locals all --clear
      dotnet workload install maui
      dotnet workload install maui-mobile
      dotnet workload install android 
      dotnet workload install maui-android      

当我调用

dotnet workload list

它显示已安装以下工作负载:

| Installed Workload Id | Manifest Version | Installation Source | |-----------------------|------------------|---------------------| | android | 33.0.68/7.0.100 | SDK 7.0.400 | | maui | 7.0.92/7.0.100 | SDK 7.0.400 | | maui-android | 7.0.92/7.0.100 | SDK 7.0.400 | | maui-mobile | 7.0.92/7.0.100 | SDK 7.0.400 |

然后我调用了命令

dotnet workload search

列出所有可用的工作负载并获得此列表:

| Workload ID | Description | |-----------------------|---------------------------------------------| | android | 用于构建Android应用程序的.NET SDK工作负载。 | | ios | 用于构建iOS应用程序的.NET SDK工作负载。 | | maccatalyst | 用于构建MacCatalyst应用程序的.NET SDK工作负载。 | | macos | 用于构建macOS应用程序的.NET SDK工作负载。 | | maui | 适用于所有平台的.NET MAUI SDK | | maui-android | 用于Android的.NET MAUI SDK | | maui-desktop | 用于桌面的.NET MAUI SDK | | maui-ios | 用于iOS的.NET MAUI SDK | | maui-maccatalyst | 用于Mac Catalyst的.NET MAUI SDK | | maui-mobile | 用于移动设备的.NET MAUI SDK | | maui-tizen | 用于Tizen的.NET MAUI SDK | | maui-windows | 用于Windows的.NET MAUI SDK | | runtimes-windows | workloads/runtimes-windows/description | | runtimes-windows-net6 | workloads/runtimes-windows-net6/description | | tvos | 用于构建tvOS应用程序的.NET SDK工作负载。 | | wasm-experimental | workloads/wasm-experimental/description | | wasm-tools | .NET WebAssembly构建工具 | | wasm-tools-net6 | .NET WebAssembly构建工具 |

要解决此问题,我尝试安装了runtimes-windows工作负载,但没有帮助。 英文:

I have a .NET MAUI mobile app project and since yesterday it was built ok in Azure DevOps until yesterday.

Then I start getting this error:

> Error NETSDK1139: The target platform identifier android was not
> recognized

I have specified target platform as net7.0-android in my csproj file.

 &lt;TargetFrameworks&gt;net7.0-android;net7.0-ios&lt;/TargetFrameworks&gt;

Upon executing this task

      - task: NuGetCommand@2
        displayName: &quot;Performing NuGet restore&quot;
        inputs:          
          command: restore
          VstsFeed: &quot;xxx.xxxx/Lib&quot;

Nuget restore has called after dotnet restore that executed ok.

      - task: NuGetAuthenticate@0
        displayName: &quot;NuGet Authenticate&quot;

      - task: DotNetCoreCLI@2
        displayName: &quot;Performing DotNet Restore&quot;
        inputs:
          command: restore
          feedsToUse: &#39;select&#39;
          VstsFeed: &quot;xxx.xxxx/Lib&quot;

      - task: NuGetCommand@2
        displayName: &quot;Performing NuGet restore&quot;
        inputs:          
          command: restore
          VstsFeed: &quot;xxx.xxxx/Lib&quot;

I suppose the windows agent image is missing some workloads now.

I install workloads using the following command:

      - task: Bash@3
        displayName: &quot;Install MAUI support&quot;
        inputs:
          targetType: &#39;inline&#39;
          script: |
                    dotnet nuget locals all --clear
                    dotnet workload install maui
                    dotnet workload install maui-mobile
                    dotnet workload install android 
                    dotnet workload install maui-android                    

And when I call

> dotnet workload list

It shows that the following workloads are installed:

| Installed Workload Id | Manifest Version | Installation Source | |-----------------------|------------------|---------------------| | android | 33.0.68/7.0.100 | SDK 7.0.400 | | maui | 7.0.92/7.0.100 | SDK 7.0.400 | | maui-android | 7.0.92/7.0.100 | SDK 7.0.400 | | maui-mobile | 7.0.92/7.0.100 | SDK 7.0.400 |

Then I called the command

> dotnet workload search

To list all available workloads and get this list:

| Workload ID | Description | |-----------------------|----------------------------------------------------------| | android | .NET SDK Workload for building Android applications. | | ios | .NET SDK Workload for building iOS applications. | | maccatalyst | .NET SDK Workload for building MacCatalyst applications. | | macos | .NET SDK Workload for building macOS applications. | | maui | .NET MAUI SDK for all platforms | | maui-android | .NET MAUI SDK for Android | | maui-desktop | .NET MAUI SDK for Desktop | | maui-ios | .NET MAUI SDK for iOS | | maui-maccatalyst | .NET MAUI SDK for Mac Catalyst | | maui-mobile | .NET MAUI SDK for Mobile | | maui-tizen | .NET MAUI SDK for Tizen | | maui-windows | .NET MAUI SDK for Windows | | runtimes-windows | workloads/runtimes-windows/description | | runtimes-windows-net6 | workloads/runtimes-windows-net6/description | | tvos | .NET SDK Workload for building tvOS applications. | | wasm-experimental | workloads/wasm-experimental/description | | wasm-tools | .NET WebAssembly build tools | | wasm-tools-net6 | .NET WebAssembly build tools |

What workload should I install to fix this issue?

I tried to install runtimes-windows workload too, but it did not help.

答案1 {#1}

得分: 1

我们遇到了相同的问题(仅从昨天开始)。我们发现问题的原因是将SDK版本从7.0.306升级到7.0.400。这次升级是在构建管道中自动执行的(可能在您的管道中也是如此)。
根据SiddheshDesai的建议,我们创建了一个global.json文件,将SDK版本硬编码为先前可工作的版本:

{
"sdk": {
"version": "7.0.306",
"rollForward": "disable"
}
}
这个解决方法允许重新构建。但是,请注意,这只是一个临时解决方法,一旦问题解决,应该将其还原。 英文:

We have seen the same issue (starting only yesterday). We found that the reason was the update of the SDK version from 7.0.306 to 7.0.400. This update was done automatically in the build pipeline (and probably in yours as well).
Using the suggestion from SiddheshDesai we created a global.json to hardcode the SDK version to the previously working version:

{
  &quot;sdk&quot;: {
    &quot;version&quot;: &quot;7.0.306&quot;,
    &quot;rollForward&quot;: &quot;disable&quot;
  }
}

This workaround allowed building again. However, this is just a temporary workaround and it should be reverted once the issue is fixed.


赞(0)
未经允许不得转载:工具盒子 » Azure Pipelines: 错误 NETSDK1139: 未识别目标平台标识符 android