简体   繁体   English

Azure DevOps Pipeline 无法找到来自其他项目的 DLL

[英]Azure DevOps Pipeline Fails DLL From Other Project Not Found

Good day,再会,

Task任务

Setup an Azure DevOps Pipeline for an ASP .NET Core 3.1 API project.为 ASP .NET Core 3.1 API 项目设置 Azure DevOps Pipeline。

Context语境

  • Both projects and the solution are located in GitHub not Azure DevOps Git.项目和解决方案都位于 GitHub 中,而不是 Azure DevOps Git。 Each of the projects is in a separate repository.每个项目都在一个单独的存储库中。 Could that be the problem?这可能是问题吗?
  • Pipeline created with Visual Studio 2019 while creating a deployment profile for the project to publish to Azure App Service.使用 Visual Studio 2019 创建的管道,同时为项目创建部署配置文件以发布到 Azure 应用服务。
  • The API project depends on a separate project containing only a class with business logic. API 项目依赖于一个单独的项目,该项目仅包含一个具有业务逻辑的类。 Both of these projects started out in the same solution.这两个项目都是从同一个解决方案开始的。
  • I can compile the solution locally with zero errors.我可以零错误地在本地编译解决方案。

Problem问题

The pipeline step that builds the project is failing due to the business logic DLL not being found.由于未找到业务逻辑 DLL,构建项目的管道步骤失败。 All prior steps are succeeding.所有先前的步骤都成功了。 This is a default pipeline created through setting up an Azure App Service publish profile for the project in Visual Studio 2019.这是通过在 Visual Studio 2019 中为项目设置 Azure 应用服务发布配置文件创建的默认管道。

What I've Tried我试过的

  • First, I've double checked that my project dependency references are correct.首先,我仔细检查了我的项目依赖项引用是否正确。 The API project depends on the DLL and the project build order is correct. API 项目依赖于 DLL,项目构建顺序正确。 The DLL project has no dependencies. DLL 项目没有依赖项。
  • After trying the pipeline with both projects under one solution, I quickly removed the DLL project from the solution, leaving only the API project.在一个解决方案下尝试了两个项目的管道后,我迅速从解决方案中删除了 DLL 项目,只留下了 API 项目。 I then tried various means to include the DLL in the API project using an assembly dependency and by manually browsing and selecting the DLL adding a project reference.然后,我尝试了各种方法,使用程序集依赖项并通过手动浏览和选择 DLL 添加项目引用来将 DLL 包含在 API 项目中。
  • I've tried adding an MS Build step in the API project file that copies out the DLL to the output directory.我尝试在 API 项目文件中添加一个 MS Build 步骤,将 DLL 复制到输出目录。 I've also selected the DLL and enabled the Copy Local property.我还选择了 DLL 并启用了 Copy Local 属性。

With the DLL project in and not in the solution the DLL is reporting as not found during the build step in the pipeline's log. DLL 项目在解决方案中而不是在解决方案中时,DLL 在管道日志中的构建步骤中报告为未找到。

Logs日志

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

This log is taken from the last pipeline run on Azure DevOps.此日志取自在 Azure DevOps 上运行的最后一个管道。

What else can I provide to help figure this out?我还能提供什么来帮助解决这个问题?

Thank you in advance for your suggestions.预先感谢您的建议。

Note: Just found this link: Add reference to Common project Azure DevOps Build Pipeline .注意:刚刚找到此链接: 添加对公共项目 Azure DevOps Build Pipeline 的引用 Am testing and have updated my question.正在测试并更新了我的问题。


Jason杰森
jas@red-expanse.com jas@red-expanse.com

These problems are generally solved with a package management solution.这些问题通常可以通过包管理解决方案来解决。

Try packaging your dll into a nuget package.尝试将您的 dll 打包到 nuget 包中。

  1. Create the nuget file in your second office在您的第二个办公室创建 nuget 文件
  2. Setup a pipeline that creates said package设置创建所述包的管道
  3. Upload your package to a local nuget server (devops provides such solution将您的包上传到本地 nuget 服务器(devops 提供了这样的解决方案

Solution / Not Really解决方案/不是真的

While not ideal, I just experimented with using Azure's Git and this time I'm not seeing the build errors.虽然不理想,但我只是尝试使用 Azure 的 Git,这次我没有看到构建错误。

  • Created Project A in Azure DevOps.在 Azure DevOps 中创建了项目 A。
  • Created Project B in Azure DevOps.在 Azure DevOps 中创建了项目 B。
  • Pushed test code to each project's repo now on Azure's Git.现在将测试代码推送到 Azure 的 Git 上的每个项目的存储库。
  • Visual Studio solution has Project A native and then Project B added as an existing project. Visual Studio 解决方案具有本机项目 A,然后将项目 B 添加为现有项目。
  • Pushed new change to Project A.对项目 A 进行了新的更改。
  • Pipeline build succeeded.管道构建成功。

Was toying with idea of switching off GitHub anyways so I can use commit tags with Azure DevOps;一直在考虑关闭 GitHub 的想法,这样我就可以在 Azure DevOps 中使用提交标签; this just pushed me to do that sooner than later.这只是促使我迟早这样做。

I am also playing with creating a Nuget package of Project B but I'm fresh new to Nuget and what tutorials I find are not for a newbie like me.我也在尝试创建 Project B 的 Nuget 包,但我是 Nuget 的新手,我找到的教程不适合像我这样的新手。 :/ :/

While I don't have a good explanation or solution, I am able to move forward with my own project.虽然我没有很好的解释或解决方案,但我可以继续自己的项目。 I apologize to future readers for not having a better answer.我向未来的读者道歉,因为没有更好的答案。 :/ :/

My only hunch is that Azure has magic to know how to see related projects in its own Git that it doesn't have to be able to see different repositories in GitHub.我唯一的预感是,Azure 拥有神奇的能力,可以知道如何在自己的 Git 中查看相关项目,而不必在 GitHub 中查看不同的存储库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM