在发布管道中找不到Autofac

时间:2019-08-14 01:59:58

标签: azure .net-core azure-devops azure-pipelines

我有一个程序MyProgram.csproj(恰好是.NET Core控制台应用程序),我正在将其版本(bin\netcoreapp2.2)复制到发布管道中并尝试运行它{{1} }通过Powershell作为任务。

这样做的时候我得到了错误

MyProgram.dll

参考是

2019-08-14T01:35:58.1153997Z     An assembly specified in the application dependencies manifest (MyProgram.deps.json) was not found:
2019-08-14T01:35:58.1154837Z     package: 'Autofac', version: '4.2.1'
2019-08-14T01:35:58.1155904Z     path: 'lib/netstandard1.1/Autofac.dll'

通过任何方式我都可以获得有关为什么找不到该程序集的更多信息?

2 个答案:

答案 0 :(得分:0)

您可以尝试将以下内容添加到我的.csproj中吗?

<PropertyGroup>
  <PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
</PropertyGroup>

并尝试更新项目上的所有引用

答案 1 :(得分:0)

摆脱依赖关系混乱的更好方法是部署一个独立的发布,因此它包括.NET Core库,.NET Core运行时和引用的包依赖关系。 通过this链接,您可以确定运行时标识符(例如win-x64)以及发布或调试版本的配置设置。

dotnet publish .\MyProgram.csproj -c Release -r "win-x64" --self-contained -o .\publish

您可以在构建定义中使用 dotnet 扩展名,也可以添加powershell内联命令来运行提及代码。

YAML示例

resources:
- repo: self
queue:
  name: DefaultAgentPool
steps:
- task: NuGetCommand@2
  displayName: 'NuGet restore'
  inputs:
    feedsToUse: config
    nugetConfigPath: nuget.config

- powershell: |
   # Write your powershell commands here.

   Write-Host "Starting dotnet cli publish command ..."
   dotnet publish --runtime "win-x64" -o $(Build.ArtifactStagingDirectory) -c Release --self-contained

  workingDirectory: src/Project
  displayName: 'dotnet publish'

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: win'
  inputs:
    ArtifactName: win-publish

这可以确保您不会在指定的运行时平台中得到任何依赖关系错误。