Reputation: 3541
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'
Upvotes: 2
Views: 2764
Reputation: 1811
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/.
Upvotes: 1
Reputation: 16163
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()
Upvotes: 2