Azure Devops - .NET 4.7.2 - 错误 MC3050:找不到类型“VsBrushes”

问题描述 投票:0回答:0

我尝试在 Azure Devops 构建服务器上构建一个 .NET 项目(Framework 4.7.2)

当我在我的电脑(VS2019 或 msbuild)上构建它时,它工作正常,但是当我在构建服务器上使用相同的命令时,我得到了这些错误。

到目前为止我看到的唯一区别是 msbuild 版本

  • 在我的电脑上:16.8.3.61104
  • 构建服务器:16.8.3+39993bd9d

这是我在 Yaml 中构建项目的方式

msbuild MyApp.csproj /property:Configuration=Release

我在构建之前尝试了恢复

dotnet restore
Get-ChildItem .\ -include obj -Recurse | foreach { remove-item $_.fullname -Force -Recurse }

感觉环境少了点什么

我也尝试添加

# Add Visual Studio environment variables to PowerShell: https://intellitect.com/enter- vsdevshell-powershell/
Write-Host "Adding Visual Studio environment variables to PowerShell"
Import-Module "C:\DevStudio\Vs2019\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"
Enter-VsDevShell -VsInstallPath C:\DevStudio\Vs2019 -SkipAutomaticLocation

这里是构建日志

##[section]Starting: Build project
==============================================================================
Task         : PowerShell
Description  : Run a PowerShell script on Linux, macOS, or Windows
Version      : 2.180.1
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/powershell
==============================================================================
Generating script.
========================== Starting Command Output ===========================
##[command]"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". '****************.ps1'"
Adding Visual Studio environment variables to PowerShell
**********************************************************************
** Visual Studio 2019 Developer PowerShell v16.8.5
** Copyright (c) 2020 Microsoft Corporation
**********************************************************************
  Determining projects to restore...
  Restored ********\MyApp.csproj (in 379 ms).
msbuild
Microsoft (R) Build Engine version 16.8.3+39993bd9d for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 3/20/2023 10:14:51 AM.
Project "********\MyApp.csproj" on node 1 (default targets).
PrepareForBuild:
  Creating directory "obj\Release\".
E:\********\SomeControl.xaml(11,14): error MC3050: Cannot find the type 'VsBrushes'. Note that type names are case sensitive. [********\MyApp.csproj]
E:\********\SomeOtherControl.xaml(15,14): error MC3050: Cannot find the type 'VsBrushes'. Note that type names are case sensitive. [********\MyApp.csproj]
E:\********\YetAnotherControl.xaml(10,14): error MC3050: Cannot find the type 'VsBrushes'. Note that type names are case sensitive. [********\MyApp.csproj]
Done Building Project "********\MyApp.csproj" (default targets) -- FAILED.

Build FAILED.

"********\MyApp.csproj" (default target) (1) ->
(MarkupCompilePass1 target) -> 
  E:\********\SomeControl.xaml(11,14): error MC3050: Cannot find the type 'VsBrushes'. Note that type names are case sensitive. [********\MyApp.csproj]
  E:\********\SomeOtherControl.xaml(15,14): error MC3050: Cannot find the type 'VsBrushes'. Note that type names are case sensitive. [********\MyApp.csproj]
  E:\********\YetAnotherControl.xaml(10,14): error MC3050: Cannot find the type 'VsBrushes'. Note that type names are case sensitive. [********\MyApp.csproj]

    0 Warning(s)
    3 Error(s)

Time Elapsed 00:00:00.68
##[error]PowerShell exited with code '1'.
##[section]Finishing: Build project

当我检查源代码时,以下警告是合法的,因为这些值应该在运行时被替换

  • 为什么在编译标记文件时无法识别 VsBrushes?
  • 我应该检查什么以进一步调查?

谢谢你帮我解决这个问题

c# powershell azure-pipelines .net-framework-version
© www.soinside.com 2019 - 2024. All rights reserved.