简体   繁体   中英

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.

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. so i checked out the .NET Framework page and there's literally no information about publishing .NET Framework app...

Does this mean that the same dotnetcore tasks apply/can be used for .NET Framework app then??

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:

在此处输入图像描述

The yaml definition:

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.

If you append the following parameters it will perform a Publish as part of a build using the VSBuild task. It may also work with the MSBuild task, I have not tried that.

Parameters to add for an ASP.NET (.NET Framework) web application:

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

VSBuild task:

- 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/.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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