【发布时间】:2021-02-01 21:16:05
【问题描述】:
早安,
任务
为 ASP .NET Core 3.1 API 项目设置 Azure DevOps Pipeline。
上下文
- 项目和解决方案都位于 GitHub 而不是 Azure DevOps Git。 每个项目都在一个单独的存储库中。 这可能是问题吗?
- 在为项目创建部署配置文件时使用 Visual Studio 2019 创建的管道 发布到 Azure 应用服务。
- API 项目依赖于一个单独的项目,该项目仅包含一个类 与业务逻辑。这两个项目都开始在 相同的解决方案。
- 我可以零错误地在本地编译解决方案。
问题
由于找不到业务逻辑 DLL,构建项目的管道步骤失败。之前的所有步骤都成功了。这是通过在 Visual Studio 2019 中为项目设置 Azure 应用服务发布配置文件创建的默认管道。
我的尝试
- 首先,我仔细检查了我的项目依赖项引用是 正确的。 API 项目依赖于 DLL 和项目构建 顺序是正确的。 DLL 项目没有依赖项。
- 在一个解决方案下尝试了两个项目的管道后,我 快速从解决方案中删除 DLL 项目,只留下 API 项目。然后我尝试了各种方法将 DLL 包含在 API 项目使用程序集依赖项并通过手动浏览和 选择 DLL 添加项目引用。
- 我尝试在 API 项目文件中添加一个 MS Build 步骤 将 DLL 复制到输出目录。我也选择了 DLL 并启用 Copy Local 属性。
如果 DLL 项目在而不是在解决方案中,则 DLL 在管道日志中的构建步骤中报告为未找到。
日志
reference:C:\hostedtoolcache\windows\dotnet\packs\Microsoft.NETCore.App.Ref\3.1.0\ref\netcoreapp3.1\System.Xml.XPath.XDocument.dll /reference:C:\hostedtoolcache\windows\dotnet\packs\Microsoft.NETCore.App.Ref\3.1.0\ref\netcoreapp3.1\WindowsBase.dll /debug+ /debug:portable /filealign:512 /optimize+ /out:obj\Release\netcoreapp3.1\ts3mpeccn.API.dll /ruleset:"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Team Tools\Static Analysis Tools\\Rule Sets\MinimumRecommendedRules.ruleset" /target:exe /warnaserror- /utf8output /deterministic+ /langversion:8.0 /analyzer:C:\hostedtoolcache\windows\dotnet\sdk\3.1.403\Sdks\Microsoft.NET.Sdk.Web\analyzers\cs\Microsoft.AspNetCore.Analyzers.dll /analyzer:C:\hostedtoolcache\windows\dotnet\sdk\3.1.403\Sdks\Microsoft.NET.Sdk.Web\analyzers\cs\Microsoft.AspNetCore.Mvc.Analyzers.dll /analyzer:C:\hostedtoolcache\windows\dotnet\sdk\3.1.403\Sdks\Microsoft.NET.Sdk.Web\analyzers\cs\Microsoft.AspNetCore.Components.Analyzers.dll Controllers\Name.cs Dto\NameDto.cs Program.cs Startup.cs "obj\Release\netcoreapp3.1\.NETCoreApp,Version=v3.1.AssemblyAttributes.cs" obj\Release\netcoreapp3.1\ts3mpeccn.API.AssemblyInfo.cs /warnaserror+:NU1605
2020-10-19T04:42:17.9436652Z Using shared compilation with compiler from directory: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Roslyn
2020-10-19T04:42:21.0045432Z ##[error]src\ts3mpeccn.API\Controllers\Name.cs(6,7): Error CS0246: The type or namespace name 'redexpanse' could not be found (are you missing a using directive or an assembly reference?)
2020-10-19T04:42:21.0067383Z 2>Controllers\Name.cs(6,7): error CS0246: The type or namespace name 'redexpanse' could not be found (are you missing a using directive or an assembly reference?) [D:\a\1\s\src\ts3mpeccn.API\ts3mpeccn.API.csproj]
2020-10-19T04:42:21.0076796Z ##[error]src\ts3mpeccn.API\Controllers\Name.cs(15,26): Error CS0246: The type or namespace name 'GivenFemaleName' could not be found (are you missing a using directive or an assembly reference?)
2020-10-19T04:42:21.0081303Z 2>Controllers\Name.cs(15,26): error CS0246: The type or namespace name 'GivenFemaleName' could not be found (are you missing a using directive or an assembly reference?) [D:\a\1\s\src\ts3mpeccn.API\ts3mpeccn.API.csproj]
2020-10-19T04:42:21.0087384Z ##[error]src\ts3mpeccn.API\Controllers\Name.cs(17,26): Error CS0246: The type or namespace name 'MiddleFemaleName' could not be found (are you missing a using directive or an assembly reference?)
2020-10-19T04:42:21.0090430Z 2>Controllers\Name.cs(17,26): error CS0246: The type or namespace name 'MiddleFemaleName' could not be found (are you missing a using directive or an assembly reference?) [D:\a\1\s\src\ts3mpeccn.API\ts3mpeccn.API.csproj]
2020-10-19T04:42:21.0097898Z ##[error]src\ts3mpeccn.API\Controllers\Name.cs(18,26): Error CS0246: The type or namespace name 'Surname' could not be found (are you missing a using directive or an assembly reference?)
2020-10-19T04:42:21.0103126Z 2>Controllers\Name.cs(18,26): error CS0246: The type or namespace name 'Surname' could not be found (are you missing a using directive or an assembly reference?) [D:\a\1\s\src\ts3mpeccn.API\ts3mpeccn.API.csproj]
2020-10-19T04:42:21.0245483Z 2>Done Building Project "D:\a\1\s\src\ts3mpeccn.API\ts3mpeccn.API.csproj" (default targets) -- FAILED.
2020-10-19T04:42:21.0341165Z 1>Done Building Project "D:\a\1\s\ts3mpeccn.API.sln" (default targets) -- FAILED.
2020-10-19T04:42:21.0377210Z
2020-10-19T04:42:21.0378012Z Build FAILED.
2020-10-19T04:42:21.0564873Z
2020-10-19T04:42:21.0587067Z "D:\a\1\s\ts3mpeccn.API.sln" (default target) (1) ->
2020-10-19T04:42:21.0587820Z "D:\a\1\s\src\ts3mpeccn.API\ts3mpeccn.API.csproj" (default target) (2) ->
2020-10-19T04:42:21.0588378Z (ResolveAssemblyReferences target) ->
2020-10-19T04:42:21.0589398Z C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2084,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "grimlock". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [D:\a\1\s\src\ts3mpeccn.API\ts3mpeccn.API.csproj]
2020-10-19T04:42:21.0591411Z
2020-10-19T04:42:21.0591610Z
2020-10-19T04:42:21.0591831Z "D:\a\1\s\ts3mpeccn.API.sln" (default target) (1) ->
2020-10-19T04:42:21.0592162Z "D:\a\1\s\src\ts3mpeccn.API\ts3mpeccn.API.csproj" (default target) (2) ->
2020-10-19T04:42:21.0592467Z (CoreCompile target) ->
2020-10-19T04:42:21.0592970Z Controllers\Name.cs(6,7): error CS0246: The type or namespace name 'redexpanse' could not be found (are you missing a using directive or an assembly reference?) [D:\a\1\s\src\ts3mpeccn.API\ts3mpeccn.API.csproj]
2020-10-19T04:42:21.0593789Z Controllers\Name.cs(15,26): error CS0246: The type or namespace name 'GivenFemaleName' could not be found (are you missing a using directive or an assembly reference?) [D:\a\1\s\src\ts3mpeccn.API\ts3mpeccn.API.csproj]
2020-10-19T04:42:21.0594630Z Controllers\Name.cs(17,26): error CS0246: The type or namespace name 'MiddleFemaleName' could not be found (are you missing a using directive or an assembly reference?) [D:\a\1\s\src\ts3mpeccn.API\ts3mpeccn.API.csproj]
2020-10-19T04:42:21.0595608Z Controllers\Name.cs(18,26): error CS0246: The type or namespace name 'Surname' could not be found (are you missing a using directive or an assembly reference?) [D:\a\1\s\src\ts3mpeccn.API\ts3mpeccn.API.csproj]
2020-10-19T04:42:21.0596153Z
2020-10-19T04:42:21.0596354Z 1 Warning(s)
2020-10-19T04:42:21.0596505Z 4 Error(s)
2020-10-19T04:42:21.0596613Z
2020-10-19T04:42:21.0596781Z Time Elapsed 00:00:05.70
2020-10-19T04:42:21.2457357Z ##[error]Process 'msbuild.exe' exited with code '1'.
2020-10-19T04:42:21.3396283Z ##[section]Finishing: Build solution ts3mpeccn.API.sln
此日志取自 Azure DevOps 上运行的最后一个管道。
我还能提供什么来帮助解决这个问题?
提前感谢您的建议。
注意:刚刚找到此链接:Add reference to Common project Azure DevOps Build Pipeline。正在测试并更新了我的问题。
杰森
jas@red-expanse.com
【问题讨论】:
-
您是否尝试过使用命令提示符在本地成功编译您的项目?告诉我们你做了什么。运行 CI 时的 Azure DevOps 基本上是在运行从恢复 nuget 包、编译、发布的整个过程。作为命令提示符中的命令序列。
-
谢谢。是的,我可以零问题地在本地编译项目。
标签: c# .net visual-studio asp.net-core azure-devops