# Azure DevOps 踩坑


讓.netCore 2.0 的測試在 Azure DevOps 中正確運行需要注意幾個地方

  1. 要增加.netCore 的測試程序集目錄;
    img
  2. 設置 Speceific location:C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\Extensions\TestPlatform 設置 Other console options:/Framework:".NETCoreApp,Version=v2.0"
    img
  3. 默認配置會包含 xunit(我是使用的 xunit)的測試程序集,這個是不需要的,會導致測試過程報錯,需要將其排除。
    img

將程序集打包發布到 Nuget 並支持遠程調試

  • 程序集的項目文件需要加入打包相關配置:
   <!-- Optional: Publish the repository URL in the built .nupkg (in the NuSpec <Repository> element) -->
   <PublishRepositoryUrl>true</PublishRepositoryUrl>
   <!-- Optional: Embed source files that are not tracked by the source control manager in the PDB -->
   <EmbedUntrackedSources>false</EmbedUntrackedSources>
   <!-- Optional: Build symbol package (.snupkg) to distribute the PDB containing Source Link -->
   <IncludeSymbols>true</IncludeSymbols>
   <SymbolPackageFormat>snupkg</SymbolPackageFormat>
   <PackageLicenseExpression>MIT</PackageLicenseExpression>

特別是License節點,在本地 push 的時候不會出問題,在 Azure DevOps 環境下 Push 沒有這個會出問題,不能夠遠程調試。

  • 引入SourceLink程序集,下面是以代碼提交到 GitHub 為例:
<ItemGroup>
   <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
</ItemGroup>

其他平台對應的 lib 可參考 https://github.com/dotnet/sourcelink

  • 然后將程序集 push 到 nuget.org 時也會同時將snupkg文件 push 到符號服務器

  • 要使用遠程調試需要對 Visual Studio 做一些配置
    img
    img


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM