Devops:错误CS0234:类型或名称空间名称'ApplicationModel'在名称空间'Windows'中不存在

时间:2018-12-16 00:51:36

标签: uwp azure-devops windows-10-sdk

我正在尝试为Windows通用示例应用程序File Access Project建立构建管道。

管道正在使用Azure管道托管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

哪里 one reference

Microsoft.UI.Xaml.Markup

它可以正常运行。

我注意到Nuget Restore任务的日志没有错误,并且会报告

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。

[更新]

我将版本更改为17134(RS4 / 1803),而不是Stefan Wick MSFT建议的版本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'

2 个答案:

答案 0 :(得分:3)

该错误是由于您的应用针对的是1809 SDK(v17763),由于某些issues,该SDK尚未在构建代理中推出。

在代理上将其发布之前,您有两种选择可以解除阻止:

  1. 如果您实际上不需要1809 SDK中的任何API,请定位1803 SDK(v17134)-或
  2. 使用this script明确安装17763 SDK依赖项

一旦有关于SDK部署以构建代理的更新,我将更新答案。

答案 1 :(得分:0)

Stefan Wick在评论中给出了答案。