Azure Devops: создание многопроектного решения в режиме выпуска, но поиск в отладке для отсутствующей сборки - PullRequest
1 голос
/ 04 июля 2019

Я пытаюсь создать мультипроектное решение в DevOps Azure для развертывания в Azure.Это решение прекрасно работает на моем локальном компьютере, но я получаю следующую ошибку сборки в Azure.

##[error]TCGTools.net\Controllers\SettingsController.cs(8,7): Error CS0246: The type or namespace name 'TCGSniperCore' could not be found (are you missing a using directive or an assembly reference?)

TCGSniperCore - это библиотека .netcore в моем решении.Проект MVC ссылается на эту библиотеку.

После просмотра полного файла журнала я обнаружил, что решение строит библиотеку .netcore в режиме выпуска, но затем ищет .dll в папке отладки.

Вывод на консоль при сборке библиотеки:

CopyFilesToOutputDirectory: 
Copying file from "obj\Release\netcoreapp2.2\TCGSniperCore.dll" to 
"bin\Release\netcoreapp2.2\TCGSniperCore.dll".
TCGSniperCore -> 
D:\a\1\s\tcgsnipercore\bin\Release\netcoreapp2.2\TCGSniperCore.dll
Copying file from "obj\Release\netcoreapp2.2\TCGSniperCore.pdb" to 
"bin\Release\netco

Вывод на консоль при сборке проекта MVC:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "TCGSniperCore". 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\TCGTools.net\TCGTools.net.csproj]
      For SearchPath "{HintPathFromItem}".
      Considered "..\tcgsnipercore\bin\Debug\netcoreapp2.2\TCGSniperCore.dll", but it didn't exist.
      For SearchPath "{RawFileName}".
      Considered treating "TCGSniperCore" as a file name, but it didn't exist.

Я пробовал следующее:

  1. Обеспечение цели обоих проектов .netcore2.2
  2. Установка пула агентов для Hosted VS2017 в DevOps Azure
  3. Установка переменной BuildConfiguration для выпуска
  4. Воспроизведение на моем локальном компьютере.Я не могу.Решение строит нормально.

Почему он ищет сборку в / debug, а не / release?

1 Ответ

0 голосов
/ 06 июля 2019

Я обнаружил, что он ищет .dll на основе пути к файлу, указанному в файле .csproj.Отредактируйте файл (я использовал VS Code) и добавьте / измените путь подсказки с помощью $ (конфигурации).

До:

<ItemGroup> 
  <Reference Include="TCGSniperCore"> 
   <HintPath>..\tcgsnipercore\bin\Debug\netcoreapp2.2\TCGSniperCore.dll</HintPath> 
  </Reference>
</ItemGroup> 

После:

<ItemGroup> 
  <Reference Include="TCGSniperCore"> 
   <HintPath>..\tcgsnipercore\bin\$(configuration)\netcoreapp2.2\TCGSniperCore.dll</HintPath> 
  </Reference>
</ItemGroup> 

Спасибо @ DJ

...