我的团队正在为客户实现一个.Net核心应用程序。对于这个实现,我们使用了一个高度可配置的.Net核心平台,其中我们在实现级别覆盖了一些功能。核心平台是受保护的(我们有两个DLL文件),这是我们在visual studio中成功构建/发布所需的。在本地机器上,它可以正确构建,但当我们尝试在Azure DevOps上配置构建/发布管道时,“启动应用程序时出现错误。DirectoryNotFoundException: C:\home\site\MyApplication\wwwroot”。
我在Azure DevOps上的存储库中有源代码,这两个dll文件也在那里。我知道如果我们有包(NuGet)而不是dll文件,事情会容易得多,但我们没有它们。我们只有dll文件。
我想我没有让它们正确地用于我的构建任务,这就是为什么我们没有正确地构建应用程序的原因。
有没有人分享YAML文件或经典部署说明,如何正确地做到这一点?
这是我的YAML,它不能工作:
# ASP.NET
# Build and test ASP.NET projects.
# Add steps that publish symbols, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/apps/aspnet/build-aspnet-4
trigger:
- main
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'
- task: CopyFiles@2
inputs:
SourceFolder: 'CoreAppFolder'
Contents: '**/.dll'
TargetFolder: '$(build.artifactStagingDirectory)'
- task: DotNetCoreCLI@2
inputs:
command: 'build'
projects: '**/*.csproj'
arguments: '--configuration $(buildConfiguration)'
- task: PublishBuildArtifacts@1发布于 2020-12-17 23:39:47
是的,我的构建通过了,发布也通过了。但是,当我点击URL查看我的站点时,我看到了这个错误。我假设构建没有被正确地完成。也许我也错了。

发布于 2021-01-01 14:16:46
CI/CD管道用于具有两个DLL文件的.Net核心应用程序,该文件存储在Azure DevOps存储库中的文件夹中-构建和发布的问题
这是因为您使用的是DotNetCoreCLI build任务而不是publish任务。
DotNetCoreCLI build的默认工作文件夹是System.DefaultWorkingDirectory。但是发布任务PublishBuildArtifacts的默认路径是$(Build.ArtifactStagingDirectory)。
因此,工件文件只包含这两个dll文件。
要解决此问题,请尝试使用DotNetCoreCLI publish任务而不是build任务:
- task: DotNetCoreCLI@2
displayName: 'dotnet publish'
inputs:
command: publish
workingDirectory: '$(Build.ArtifactStagingDirectory)'https://stackoverflow.com/questions/65333154
复制相似问题