简体   繁体   English

Azure 管道 - dotnet 发布覆盖 VSBuild.zip 然后抱怨找不到它们

[英]Azure pipelines - dotnet publish overwriting VSBuild .zip's then complaining it can't find them

My.sln consists of several projects (.cspoj) with a mix of targeting frameworks including .netcore and a selection of .net frameworks. My.sln 由多个项目 (.cspoj) 组成,其中包含多种目标框架,包括 .netcore 和一系列 .net 框架。

Some of these projects are web projects which need to be built and include other non-web projects in their packages.其中一些项目是 web 项目,需要构建并在其包中包含其他非 Web 项目。

This is essentially a teamcity to azure devops migration - I figured using vsbuild and then dotnetcorecli 'publish' would give me the required packages (publish command does find the correct webapps).这本质上是 azure devops 迁移的团队城市 - 我认为使用 vsbuild 然后 dotnetcorecli 'publish' 会给我所需的包(publish 命令确实找到了正确的 webapps)。

My issue is that after VSBuild I have oneproject.zip in my "artifact staging dir", the dotnet publish command afterwards, which is set to output into "artifact staging dir/publish", simply erases all content from "oneproject.zip" and then complains it cannot find "oneproject", please see the error output below the pipeline.我的问题是,在VSBuild之后,我的“工件暂存目录”中有oneproject.zip,之后的dotnet发布命令设置为output到“工件暂存目录/发布”,只需删除“oneproject.zip”中的所有内容并然后抱怨它找不到“oneproject”,请参阅管道下方的错误 output。

Here is my annotated and condensed pipeline这是我的注释和压缩管道

pool: selfhosted

using a self hosted agent, with msbuildtools/vs studio/node/npm使用自托管代理,带有 msbuildtools/vs studio/node/npm

variables:
  solution: '**/mainsolution.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Debug'

global variables全局变量

stages:
    - stage: build_main
      displayName: 'Build Main'
      jobs:

using stages, to prevent overwriting source files by grouping tasks使用阶段,通过分组任务来防止覆盖源文件

      - job: multijob
        steps:
        - task: NuGetToolInstaller@1
          displayName: 'install nuget'
        - task: NuGetCommand@2
          displayName: 'NuGet restore'
          inputs:
            command: 'restore'
            restoreSolution: '$(solution)'
            feedsToUse: 'select'
            vstsFeed: 'myvstsfeed'

installing nuget, and restoring from an azure artifacts feed安装 nuget,并从 azure 工件源恢复

        - task: DotNetCoreCLI@2
          displayName: 'dotnet restore'
          inputs:
           command: 'restore'
           projects: '**/mainsolution.sln'
           feedsToUse: 'select'
           vstsFeed: 'myvstsfeed'

VSBuild - Building the main.sln which references all.csproj's , and a separate MSBuild for another odd project.* VSBuild - 构建引用 all.csproj's 的 main.sln ,并为另一个奇怪的项目构建单独的 MSBuild。*

        - task: VSBuild@1
          displayName: 'Build Solution'
          inputs:
            solution: '$(solution)'
            msbuildArgs: '
            /p:DeployOnBuild=true 
            /p:WebPublishMethod=Package 
            /p:PackageAsSingleFile=true 
            /p:SkipInvalidConfigurations=true 
            /p:PackageLocation="$(Build.ArtifactStagingDirectory)"'
            platform: '$(BuildPlatform)'
            configuration: '$(BuildConfiguration)'
        - task: VSBuild@1
          displayName: 'Build oddproject'
          inputs:
            solution: '**/oddproject/oddproject.csproj'
            msbuildArgs: '
            /p:DeployOnBuild=true 
            /p:WebPublishMethod=Package 
            /p:PackageAsSingleFile=true 
            /p:SkipInvalidConfigurations=true 
            /p:PackageLocation="$(Build.ArtifactStagingDirectory)"'
            platform: '$(BuildPlatform)'
            configuration: '$(BuildConfiguration)'

This is the problem, my publish step这是问题,我的发布步骤

        - task: DotNetCoreCLI@2
          inputs:
           command: 'publish'
           publishWebProjects: true
           arguments: '--configuration $(BuildConfiguration) -o published'

##[debug]Zip arguments: Source: published\oneproject, target: published\oneproject.zip ##[debug]Zip arguments:来源:published\oneproject,目标:published\oneproject.zip

##[error]Error: ENOENT: no such file or directory, open 'A:\agent_work\2\s\published\oneproject.zip' ##[错误]错误:ENOENT:没有这样的文件或目录,打开 'A:\agent_work\2\s\published\oneproject.zip'


  1. why is it looking for a source directory in my output folder and not a.zip from VSBuild's output?为什么它在我的 output 文件夹中寻找目录,而不是 VSBuild 的 output 中的 a.zip?
  2. why does it delete the zip files contents?为什么它会删除 zip 文件内容?
  3. I was unable to specify vsbuild to output into the filesystem without zipping.在没有压缩的情况下,我无法将 output 的 vsbuild 指定到文件系统中。
  4. trying an extract command failed, as the zip is extracted excluding the project name (straight to content).尝试提取命令失败,因为 zip 被提取,不包括项目名称(直接到内容)。 Also using a ramdisk for my _work, so would prefer a more memory managed approach.还为我的 _work 使用 ramdisk,因此更喜欢 memory 托管方法。

I really appreciate any inputs or critique on this.我非常感谢对此的任何意见或批评。 Let me know if there's anything useful I can provide as well.让我知道我是否也可以提供任何有用的东西。 <3 <3

Looks like "oneproject.csproj" wasn't a solution that could be built with dotnetcorecli.看起来“oneproject.csproj”不是可以使用 dotnetcorecli 构建的解决方案。 After isolating the correct projects to separate into vsbuild and dotnetpublish - the build progressed.在隔离正确的项目以分离为 vsbuild 和 dotnetpublish 之后 - 构建进行了。 I then had node and gulp issues, but those were solved by installing an older version (or any version from a build machine able to build it, node/gulp -v).然后我遇到了 node 和 gulp 问题,但是通过安装旧版本(或能够构建它的构建机器的任何版本,node/gulp -v)解决了这些问题。

I solved the artifact path issue by manually archiving the output of every vsbuild webproject's 'packagetmp' folder into artifact staging.我通过手动将每个 vsbuild webproject 的“packagetmp”文件夹的 output 归档到工件暂存中来解决工件路径问题。

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

相关问题 Azure Devops 管道 do.net 发布任务忽略项目设置 - Azure Devops Pipelines dotnet publish task ignores projects setting Azure Pipelines:使用 -o 构建 dotnet 后 dotnet 测试失败 - “找不到任何兼容的框架版本” - Azure Pipelines: dotnet test fails after dotnet build with -o - "It was not possible to find any compatible framework version" 为什么 VSCode 的 C# 扩展找不到 dotnet? - Why can't VSCode's C# extension find dotnet? dotnet publish 不会为 Azure Functions 创建 bin 文件夹 - dotnet publish doesn't create a bin folder for Azure Functions 如何更改 Azure Devops 上的 VSBuild 代理位置? - How can I change the VSBuild agent location on Azure Devops? Azure管道:任务PublishBuildArtifacts避免zip - Azure Pipelines: task PublishBuildArtifacts avoid zip 尝试通过 dotnet publish 命令发布 azure 函数 - Trying to publish an azure function via dotnet publish command MVC发布后找不到依赖项 - MVC can't find dependency after publish Zip N IEnumerable <T> 在一起? 同时迭代它们? - Zip N IEnumerable<T>s together? Iterate over them simultaneously? Azure DevOps Build Pipeline:“publish”命令正在执行“dotnet build”而不是“dotnet publish” - Azure DevOps Build Pipeline: 'publish' command is executing 'dotnet build' instead of 'dotnet publish'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM