uwp - Devops:错误 CS0234:命名空间“Windows”中不存在类型或命名空间名称“ApplicationModel”
问题描述
我正在尝试为 Windows Universal Sample Application File Access Project设置构建管道。
管道使用 Azure Pipelines Hosted VS2017 Image
当我在本地 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'
该项目在我的机器上看起来像这样
它运行正确。
我注意到 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 是如何知道这一点的。事实上,我想知道为什么它在路径中有关于机器学习的东西。
[更新]
根据 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'
解决方案
该错误是由于您的应用程序针对的是 1809 SDK (v17763),由于某些问题,该 SDK 尚未在构建代理上推出。
在它在代理上推出之前,您有两个选项可以解锁:
- 如果您实际上不需要来自 1809 SDK 的任何 API,则以 1803 SDK (v17134) 为目标 - 或
- 使用此脚本显式安装 17763 SDK 依赖项
一旦有关于构建代理的 SDK 推出的更新,我将更新答案。
推荐阅读
- c# - 如何在多个变量中获取多个文件的目录?
- java - 修改具有 jsonpath 的 Json
- vue.js - 如何在 Linux 上安装 zurb 基础
- r - 如何获取 MA 图的基础数据?
- python - 如何在不更新其余包的情况下使用 pipenv 安装/更新包
- javascript - 如何阻止键盘在硬件后退按钮按下(onKeyDown)时解除?
- r - 如何在向量头中计算 NA?
- sql-server - 在 SQL Server 2012 中正确使用 IF ELSE 子句
- c - 为什么在 C 中允许的函数中返回堆栈分配的指针变量?
- grails - grails 如何在后台获取 cassandraTemplate 实例?