簡體   English   中英

Devops:錯誤 CS0234:命名空間“Windows”中不存在類型或命名空間名稱“ApplicationModel”

[英]Devops: Error CS0234: The type or namespace name 'ApplicationModel' does not exist in the namespace 'Windows'

我正在嘗試為 Windows 通用示例應用程序文件訪問項目設置構建管道。

管道使用 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'

該項目在我的機器上看起來像這樣

項目參考

在哪里一個參考

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 是如何知道這一點的。 事實上,我想知道為什么它在路徑中包含機器學習。

[更新]

我按照 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 尚未在構建代理上推出。

在它在代理上推出之前,您有兩種選擇可以解除封鎖:

  1. 如果您實際上不需要來自 1809 SDK 的任何 API,則以 1803 SDK (v17134) 為目標 - 或者
  2. 使用此腳本顯式安裝 17763 SDK 依賴項

一旦有關於構建代理的 SDK 部署的更新,我將更新答案。

Stefan Wick在評論中給出了答案。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM