【问题标题】:Error in CICD pipeline build while Deploying single project from multi-project .NET solution with Azure DevOps使用 Azure DevOps 从多项目 .NET 解决方案部署单个项目时 CICD 管道构建出错
【发布时间】:2020-04-27 01:49:30
【问题描述】:

我正在尝试使用 CICD 从多项目 .net 解决方案构建单个 cs 项目,但它在 MSBuild 中出现错误。我正在使用boilerplate。以下是我的管道的步骤:

在构建中,我遇到了一些程序集引用错误,例如

Error CS0246: The type or namespace name 'Abp' could not be found (are you missing a using directive or an assembly reference?)
Error CS0246: The type or namespace name 'FullAuditedEntity' could not be found (are you missing a using directive or an assembly reference?)
Error CS0246: The type or namespace name 'DependsOnAttribute' could not be found (are you missing a using directive or an assembly reference?)
Error CS0246: The type or namespace name 'DependsOn' could not be found (are you missing a using directive or an assembly reference?)
Error CS0246: The type or namespace name 'AbpZeroCoreModule' could not be found (are you missing a using directive or an assembly reference?)
Error CS0246: The type or namespace name 'AbpZeroLdapModule' could not be found (are you missing a using directive or an assembly reference?)
Error CS0246: The type or namespace name 'ILocalizableString' could not be found (are you missing a using directive or an assembly reference?)

【问题讨论】:

  • 如果该项目是asp.net核心项目,我建议你使用dotnet restore任务而不是nuget restore任务。查看Nuget任务中的Note,可以看到:Using or creating .NET Core or .NET Standard packages? Use the .NET Core task, which has full support for all package scenarios currently supported by dotnet, including restore, pack, and nuget push.

标签: visual-studio azure-devops visual-studio-2017 azure-pipelines aspnetboilerplate


【解决方案1】:

错误 CS0246:找不到类型或命名空间名称“Abp”(是 您缺少 using 指令或程序集引用?)错误 CS0246: 找不到类型或命名空间名称“FullAuditedEntity”(是 您缺少 using 指令或程序集引用?)......

这些错误表明boilerplate相关程序集没有成功恢复。所以你的实际问题可能来自nuget restore 步骤。

为此:

1.确保您的项目通过nuget packages(Boilerplate,Abp.AspNetCore...)引用boilerplate相关程序集

2.检查您的nuget restore task 日志并确保您可以看到如下内容:

如果您看不到此消息,请尝试使用dotnet restore task + **/*.sln 为您的项目恢复包。

希望对你有帮助:)

【讨论】:

  • 这些缺失的程序集是来自 nuget.org 还是您的 devops 提要?也许这是关于包源的一个问题,您能否分享一些有关您遇到的新错误的详细信息?我会尽快检查的。
  • @ Lance Li-MSFT 现在,如果我使用 dotnet restore 任务,它会给出一些未找到的程序集错误
  • @user3099388 您的解决方案是否同时包含 .net 框架和 .net 核心项目?如果是这样,您需要对 .net 框架项目使用 nuget restore,对那些 .net 核心项目使用 dotnet restore。 (这意味着您不能对整个解决方案使用简单的 nuget restore 或 dotnet restore)。
【解决方案2】:

"D:\a\9\s.nuget\NuGet.exe" 安装 "D:\a\9\s{projectname}\packages.config" -source "" -NonInteractive -RequireConsent -solutionDir "D: \a\9\s\ "

正在恢复 NuGet 包... 要防止 NuGet 在构建期间下载包,请打开 Visual Studio 选项对话框,单击包管理器节点并取消选中“允许 NuGet 下载丢失的包”。

##[error].nuget\NuGet.targets(100,9):错误:找不到包“Microsoft.IdentityModel.Clients.ActiveDirectory”的版本“3.19.6”。 D:\a\9\s.nuget\NuGet.targets(100,9):错误:找不到包“Microsoft.IdentityModel.Clients.ActiveDirectory”的版本“3.19.6”。 [D:\a\9\s{项目名称}{项目名称}.csproj]

##[error].nuget\NuGet.targets(100,9):错误:找不到包“Microsoft.PowerBI.Api”的版本“2.0.12”。 D:\a\9\s.nuget\NuGet.targets(100,9):错误:找不到包“Microsoft.PowerBI.Api”的版本“2.0.12”。 [D:\a\9\s{项目名称}{项目名称}.csproj]

##[error].nuget\NuGet.targets(100,9):错误:找不到包“Microsoft.Rest.ClientRuntime”的版本“2.3.11”。 D:\a\9\s.nuget\NuGet.targets(100,9):错误:找不到包“Microsoft.Rest.ClientRuntime”的版本“2.3.11”。 [D:\a\9\s{项目名称}{项目名称}.csproj]

##[error].nuget\NuGet.targets(100,9):错误:找不到包“System.Collections.Immutable”的版本“1.7.0”。 D:\a\9\s.nuget\NuGet.targets(100,9):错误:找不到包“System.Collections.Immutable”的版本“1.7.0”。 [D:\a\9\s{项目名称}{项目名称}.csproj]

##[error].nuget\NuGet.targets(100,9):错误:找不到包“System.ValueTuple”的版本“4.5.0”。 D:\a\9\s.nuget\NuGet.targets(100,9):错误:找不到包“System.ValueTuple”的版本“4.5.0”。 [D:\a\9\s{项目名称}{项目名称}.csproj]

[错误].nuget\NuGet.targets(100,9):错误 MSB3073:命令“”D:\a\9\s.nuget\NuGet.exe

" install "D:\a\9\s{projectname}\packages.config" -source "" -NonInteractive -RequireConsent -solutionDir "D:\a\9\s\ "" 以代码 1 退出。 D:\a\9\s.nuget\NuGet.targets(100,9): 错误 MSB3073: 命令 ""D:\a\9\s.nuget\NuGet.exe" install "D:\a\9\s{projectname}\packages.config" -source "" -NonInteractive -RequireConsent -solutionDir "D:\a\9\s\ "" 退出,代码为 1。 [D:\a \9\s{项目名称}{项目名称}.csproj]

完成构建项目“D:\a\9\s{projectname}{projectname}.csproj”(默认目标)--失败。

【讨论】:

    猜你喜欢
    • 2021-11-26
    • 1970-01-01
    • 2016-05-17
    • 1970-01-01
    • 2019-07-29
    • 2021-05-25
    • 2019-12-05
    • 2015-04-16
    • 1970-01-01
    相关资源
    最近更新 更多