Reputation: 3551
What do I need to specify for the root file/folder in publish task for MSBuild "Release"?
Is the .NET release basically the binaries? Because for AngularOutput build I had to specify path of the AngularOutput, but for .NET Release, I am not sure what path that would be, I would think it's the entire project, which means... it's the binaries?
Expected artifact:
Resulting artifact following Kevin's YAML:
Inside _PublishedWebsites:
When running on Windows agent:
Using VSBuild:
steps:
- task: VSBuild@1
displayName: '.Net build | Build solution'
inputs:
solution: 'Project123/*.csproj'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactstagingdirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
platform: AnyCPU
configuration: Release
msbuildArchitecture: x64
Result is the same, placed in long path:
Using /p:PublishProfile=Project123.pubxml
MSBuild arg instead, and running on windows agent, the build completes just fine but this time. I get this warning for Publish Task:
##[warning]Directory 'D:\a\1\a' is empty. Nothing will be added to build artifact 'Release'.
I tried adding /p:OutputPath=$(build.artifactstagingdirectory)
to the MSBuild args alongside the publish profile arg, and the result is the same one I posted before:
Actually do we even need /p:DeployOnBuild=true
? I understand that is to deploy, but I don't think we want or should deploy yet in the pipeline because we have a Release for that specifically to deploy the published artifacts to the App Service.
Upvotes: 1
Views: 2948
Reputation: 35554
What do i need to specify for the root file/folder in publish task for MSBuild "Release"?
When you use the Msbuild task to build your project, the output file will be saved at the Bin folder by default. For example: $(build.sourcesdirectory)/Projectname/bin
.
Based on the structure of your project, the specific path could be different.
I suggest that you could add msbuild arguments(e.g. /p:OutputPath=$(build.artifactstagingdirectory)
) in the Msbuild task.
For example:
In this case, you could set a specific path as the output path. This will make it easier for you to Archive and Publish artifacts.
Update:
Ubuntu agent:
If I don't set the msbuild arg, the output files will show in the bin folder:
When I add the msbuild arg, it will upload the files to the target path:
They have the same artifacts contents.
Update2:
You could try the following sample to create the package for Azure APP service.
Classic :
Yaml:
steps:
- task: NuGetToolInstaller@0
displayName: 'Use NuGet 4.4.1'
inputs:
versionSpec: 4.4.1
- task: NuGetCommand@2
displayName: 'NuGet restore'
inputs:
restoreSolution: Sample.sln
- task: MSBuild@1
displayName: 'Build solution Sample.sln'
inputs:
solution: Sample.sln
platform: '$(BuildPlatform)'
configuration: Release
msbuildArguments: '/p:OutputPath=$(build.artifactstagingdirectory)'
- task: ArchiveFiles@2
displayName: 'Archive $(Build.ArtifactStagingDirectory)'
inputs:
rootFolderOrFile: '$(Build.ArtifactStagingDirectory)'
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact'
inputs:
PathtoPublish: '$(build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
condition: succeededOrFailed()
Result:
Update3:
steps:
- task: NuGetToolInstaller@0
displayName: 'Use NuGet 4.4.1'
inputs:
versionSpec: 4.4.1
- task: NuGetCommand@2
displayName: 'NuGet restore'
inputs:
restoreSolution: Sample.sln
- task: MSBuild@1
displayName: 'Build solution Sample.Web/Sample.Web.csproj'
inputs:
solution: Sample.Web/Sample.Web.csproj
platform: '$(BuildPlatform)'
configuration: Release
msbuildArguments: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactstagingdirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: drop'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
Upvotes: 1