简体   繁体   English

.NET 框架是否有发布任务? (不是 .NET 核心)

[英]Is there a publish task for .NET Framework? (NOT .NET Core)

According to MSDocs here , there is a task to publish .NET Core with arguments.根据此处的 MSDocs,有一项任务是发布 .NET Core 和 arguments。

dotnet publish --output $(Build.ArtifactStagingDirectory)

But I have a .NET Framework application, not .NET Core, which means i use MSBuild task not dotnetcore task to build .NET.但是我有一个 .NET 框架应用程序,而不是 .NET 核心,这意味着我使用 MSBuild 任务而不是 dotnetcore 任务来构建 Z303CB0EF9EDB25D9082AZD61BBBE88 so i checked out the .NET Framework page and there's literally no information about publishing .NET Framework app...所以我查看了.NET 框架页面,实际上没有关于发布 .NET 框架应用程序的信息...

Does this mean that the same dotnetcore tasks apply/can be used for .NET Framework app then??这是否意味着相同的 dotnetcore 任务适用/可用于 .NET 框架应用程序呢?

steps:

- task: DotNetCoreCLI@2
  inputs:
    command: publish
    publishWebProjects: True
    arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)'
    zipAfterPublish: True

# this code takes all the files in $(Build.ArtifactStagingDirectory) and uploads them as an artifact of your build.
- task: PublishBuildArtifacts@1
  inputs:
    pathtoPublish: '$(Build.ArtifactStagingDirectory)' 
    artifactName: 'myWebsiteName'

The following build works on the ubuntu build agent:以下构建适用于 ubuntu 构建代理:

在此处输入图像描述

The yaml definition: yaml 定义:

steps:

- task: NuGetToolInstaller@1    
  displayName: 'Use NuGet '    

- task: NuGetCommand@2    
  displayName: 'NuGet restore'    
  inputs:    
    restoreSolution: '<my_path>.sln'    

- task: MSBuild@1    
  displayName: 'Build solution <my_path>.sln'    
  inputs:    
    solution: '<my_path>.sln'    
    platform: '$(BuildPlatform)'    
    configuration: '$(BuildConfiguration)'    

- task: CopyFiles@2    
  displayName: 'Copy Files to: $(build.artifactstagingdirectory)'    
  inputs:    
    SourceFolder: '$(system.defaultworkingdirectory)'    
    Contents: '**/bin/**'    
    TargetFolder: '$(build.artifactstagingdirectory)'    
  condition: succeededOrFailed()
       
- task: PublishBuildArtifacts@1    
  displayName: 'Publish Artifact: drop'    
  inputs:    
    PathtoPublish: '$(build.artifactstagingdirectory)'    
  condition: succeededOrFailed()

dotnet publish / DotNetCoreCLI@2 publish task only works for .NET Core and above. dotnet publish / DotNetCoreCLI@2 publish 任务仅适用于 .NET Core 及更高版本。

If you append the following parameters it will perform a Publish as part of a build using the VSBuild task.如果 append 使用以下参数,它将使用 VSBuild 任务执行发布作为构建的一部分。 It may also work with the MSBuild task, I have not tried that.它也可能适用于 MSBuild 任务,我没有尝试过。

Parameters to add for an ASP.NET (.NET Framework) web application:为 ASP.NET (.NET Framework) web 应用程序添加的参数:

'/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(Build.ArtifactStagingDirectory)/Build/"'

VSBuild task: VSBuild 任务:

- task: VSBuild@1
  inputs:
    solution: $(solutionFileName)    
    vsVersion: ${{ parameters.visualStudioVersion }}
    platform: '${{ parameters.platform }}'
    configuration: 'Release' 
    msbuildArgs: '$(msBuildArgs)'

The packaged.zip will be found in $(Build.ArtifactStagingDirectory)/Build/.打包后的.zip 将在 $(Build.ArtifactStagingDirectory)/Build/ 中找到。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM