Devops:错误 CS0234:命名空间“Windows"中不存在类型或命名空间名称“ApplicationModel" [英] Devops: Error CS0234: The type or namespace name 'ApplicationModel' does not exist in the namespace 'Windows'

查看:103
本文介绍了Devops:错误 CS0234:命名空间“Windows"中不存在类型或命名空间名称“ApplicationModel"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为 Windows 通用示例应用程序设置构建管道

哪里

而且它运行正常.

我注意到 Nuget Restore 任务的日志没有错误并且确实报告了

2018-12-16T01:27:31.8700773Z 检查 Microsoft.NETCore.Targets.UniversalWindowsPlatform 5.0.0 与 UAP 的兼容性,Version=v10.0 (win10-x86-aot).2018-12-16T01:27:31.8700831Z 检查 Microsoft.NETCore.Platforms 1.0.0 与 UAP 的兼容性,版本 = v10.0 (win10-x86-aot).2018-12-16T01:27:31.8700878Z 所有包和项目都兼容 UAP,Version=v10.0 (win10-x86-aot).

[更新]

查看SDK在我机器上的位置

C:Program Files (x86)Windows Kits10References10.0.17763.0Windows.AI.MachineLearning.MachineLearningContract1.0.0.0

我想知道 Nuget 是怎么知道的.事实上,我想知道为什么它在路径中包含机器学习.

[更新]

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

错误更改为

C:Program Files (x86)Microsoft Visual Studio2017EnterpriseMSBuildMicrosoftVisualStudiov15.0AppxPackageMicrosoft.AppXPackage.Targets(3218,5):错误 APPX0101:需要签名密钥为了打包这个项目.请指定 PackageCertificateKeyFile 或项目文件中的 PackageCertificateThumbprint 值.进程msbuild.exe"以代码1"退出.SharedContentTemplatesUWPSDKSampleCPPARMDebugUWPSDKSampleCPPAppxManifest.xml(0,0):错误 APPX0501:验证错误.错误 C00CE169:应用清单验证错误:应用清单必须根据架构有效:第 10 行,第 13 列,原因:'Microsoft.SDKSamples.$safeprojectname$.CPP' 违反模式'[-.A-Za-z0-9]+' 的约束.带有值的属性名称"'Microsoft.SDKSamples.$safeprojectname$.CPP' 解析失败.进程msbuild.exe"以代码1"退出.SharedContentTemplatesUWPSDKSampleCSinARMDebugAppxManifest.xml(0,0):错误 APPX0501:验证错误.错误 C00CE169:应用清单验证错误:应用清单必须根据架构有效:第 10 行,第 13 列,原因:Microsoft.SDKSamples.$safeprojectname$.CS"违反了[-.A-Za-z0-9]+"的模式约束.无法解析值为Microsoft.SDKSamples.$safeprojectname$.CS"的属性Name".进程 'msbuild.exe' 退出,代码为 '1'

解决方案

该错误是由于您的应用面向 1809 SDK (v17763),该 SDK 尚未在构建代理上推出,原因是一些问题.

在它在代理上推出之前,您有两种选择可以解除封锁:

  1. 如果您实际上不需要来自 1809 SDK 的任何 API,请以 1803 SDK (v17134) 为目标 - 或
  2. 使用这个脚本明确安装17763 SDK 依赖项

一旦有关于 SDK 推出以构建代理的更新,我将更新答案.

I am trying to set up a build pipeline for the Windows Universal Sample Application File Access Project.

The pipeline is using the Azure Pipelines Hosted VS2017 Image

The solution builds when I run it in VS locally.

Package.appxmanifest contains

<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.10586.0" MaxVersionTested="10.0.17763.0" />

When the pipeline tries to build the following error appears in the build task log.

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

The YAML is

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

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


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

The project looks like this on my machine

Where

And it runs correctly.

I notice the log for the Nuget Restore task has no errors and does report

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).

[Update]

Looking at the location on my machine of the SDK

C:Program Files (x86)Windows Kits10References10.0.17763.0Windows.AI.MachineLearning.MachineLearningContract1.0.0.0

I wonder how Nuget is meant to know about that. Indeed I wonder why it has something about MachineLearning in the path.

[Update]

I changed versions to 17134 (RS4/1803) instead of 17763 (RS5/1809) as suggested by Stefan Wick MSFT

The errors changed to

C:Program Files (x86)Microsoft Visual Studio2017EnterpriseMSBuildMicrosoftVisualStudiov15.0AppxPackageMicrosoft
.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'.
SharedContentTemplatesUWPSDKSampleCPPARMDebugUWPSDKSampleCPPAppxManifest.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'.
SharedContentTemplatesUWPSDKSampleCSinARMDebugAppxManifest.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'

解决方案

The error is due to the fact that your app is targeting the 1809 SDK (v17763), which has not been rolled out on the build agents yet, due to some issues.

Until it has been rolled out on the agents, you have two options to get unblocked:

  1. Target the 1803 SDK (v17134) if you don't actually need any APIs from the 1809 SDK - or
  2. Use this script to explicitely install the 17763 SDK dependency

I will update the answer once there is an update regarding the SDK rollout to build agents.

这篇关于Devops:错误 CS0234:命名空间“Windows"中不存在类型或命名空间名称“ApplicationModel"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆