英文:
Azure Pipelines: Error NETSDK1139: The target platform identifier android was not recognized
问题
我有一个.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.
<TargetFrameworks>net7.0-android;net7.0-ios</TargetFrameworks>
Upon executing this task
- task: NuGetCommand@2
displayName: "Performing NuGet restore"
inputs:
command: restore
VstsFeed: "xxx.xxxx/Lib"
Nuget restore has called after dotnet restore
that executed ok.
- task: NuGetAuthenticate@0
displayName: "NuGet Authenticate"
- task: DotNetCoreCLI@2
displayName: "Performing DotNet Restore"
inputs:
command: restore
feedsToUse: 'select'
VstsFeed: "xxx.xxxx/Lib"
- task: NuGetCommand@2
displayName: "Performing NuGet restore"
inputs:
command: restore
VstsFeed: "xxx.xxxx/Lib"
I suppose the windows agent image is missing some workloads now.
I install workloads using the following command:
- task: Bash@3
displayName: "Install MAUI support"
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
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
我们遇到了相同的问题(仅从昨天开始)。我们发现问题的原因是将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:
{
"sdk": {
"version": "7.0.306",
"rollForward": "disable"
}
}
This workaround allowed building again. However, this is just a temporary workaround and it should be reverted once the issue is fixed.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论