DevOps: 错误 CS0234:命名空间 'Windows' 中不存在类型或命名空间名称为 'ApplicationModel' 的项

7
我正在尝试为Windows通用示例应用程序文件访问项目设置构建流水线。
该流水线使用Azure Pipelines托管的VS2017映像。
当我在本地运行VS时,解决方案可以成功构建。
Package.appxmanifest包含以下内容:
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.10586.0" MaxVersionTested="10.0.17763.0" />

当管道尝试构建时,构建任务日志中出现以下错误。

Error CS0234: The type or namespace name 'ApplicationModel' 
does not exist in the namespace 'Windows' 
(are you missing an assembly reference?)

YAML是

resources:
- repo: self
queue:
  name: Hosted VS2017
  demands: 
  - msbuild
  - visualstudio

steps:
- task: NuGetCommand@2
  displayName: 'NuGet restore'


- task: VSBuild@1
  displayName: 'Build solution **\*.sln'

这个项目在我的机器上看起来像这样

project references

在哪里 一个参考

Microsoft.UI.Xaml.Markup

我注意到Nuget恢复任务的日志没有错误并且有报告。

它可以正确运行。

2018-12-16T01:27:31.8700773Z Checking compatibility for Microsoft.NETCore.Targets.UniversalWindowsPlatform 5.0.0 with UAP,Version=v10.0 (win10-x86-aot).
2018-12-16T01:27:31.8700831Z Checking compatibility for Microsoft.NETCore.Platforms 1.0.0 with UAP,Version=v10.0 (win10-x86-aot).
2018-12-16T01:27:31.8700878Z All packages and projects are compatible with UAP,Version=v10.0 (win10-x86-aot).

[更新]

查看我机器上SDK的位置

C:\Program Files (x86)\Windows Kits\10\References\10.0.17763.0\Windows.AI.MachineLearning.MachineLearningContract\1.0.0.0

我想知道Nuget如何知道那个问题。实际上,我想知道为什么它在路径中有MachineLearning相关内容。

[更新]

我按照Stefan Wick MSFT的建议将版本更改为17134(RS4/1803),而不是17763(RS5/1809)

错误信息已更改为

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\VisualStudio\v15.0\AppxPackage\Microsoft
.AppXPackage.Targets(3218,5): Error APPX0101: A signing key is required in 
order to package this project. Please specify a PackageCertificateKeyFile or 
PackageCertificateThumbprint value in the project file.
Process 'msbuild.exe' exited with code '1'.
SharedContent\Templates\UWPSDKSampleCPP\ARM\Debug\UWPSDKSampleCPP\AppxManifest.xml(0,0):

Error APPX0501: Validation error. error C00CE169: App manifest validation 
error: The app manifest must be valid as per schema: Line 10, Column 13, 
Reason: 'Microsoft.SDKSamples.$safeprojectname$.CPP' violates pattern 
constraint of '[-.A-Za-z0-9]+'. The attribute 'Name' with value 
'Microsoft.SDKSamples.$safeprojectname$.CPP' failed to parse.
Process 'msbuild.exe' exited with code '1'.
SharedContent\Templates\UWPSDKSampleCS\bin\ARM\Debug\AppxManifest.xml(0,0): 
Error APPX0501: Validation error. error C00CE169: App manifest validation error: 
The app manifest must be valid as per schema: Line 10, Column 13, Reason: 'Microsoft.SDKSamples.$safeprojectname$.CS' violates pattern constraint of '[-.A-Za-z0-9]+'. 
The attribute 'Name' with value 'Microsoft.SDKSamples.$safeprojectname$.CS' failed to parse.
Process 'msbuild.exe' exited with code '1'

NuGet还原步骤的输出是什么? - Daniel Mann
@DanielMann Nuget任务的日志太大了,无法粘贴,但没有错误。 - Kirsten
2
如果你的目标是17134(RS4/1803),而不是17763(RS5/1809),它是否能正常工作?代理可能尚未安装1809 SDK。 - Stefan Wick MSFT
https://stackoverflow.com/questions/53807130/devops-error-cs0103-the-name-windows-does-not-exist-in-the-current-context 是一个类似但不完全相同的问题。 - Kirsten
@StefanWickMSFT,能否给我们写下答案呢? - Kirsten
1个回答

8

这个错误是因为你的应用程序针对1809 SDK(v17763)进行了定位,但由于一些问题,它还没有在构建代理上发布。

在代理上发布之前,你有两个选择来解决阻塞:

  1. 如果你实际上不需要1809 SDK中的任何API,则针对1803 SDK(v17134)进行定位 - 或者
  2. 使用此脚本显式安装17763 SDK依赖项

一旦有关SDK在构建代理上的发布方面有更新,我将更新答案。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接