0
votes

What do i need to specify for the root file/folder in publish task for MSBuild "Release"?

MSBuild

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 its the entire project, which means...its the binaries?

binaries

expected artifact:

expected

UPDATE: Resulting artifact following Kevin's YAML:

root

inside _PublishedWebsites

inside


Following update3, when running on windows agent:

windows

Update#4: 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:

VS

update#5: 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:

result2

Remark:

Actually do we even need /p:DeployOnBuild=true? I understand that is to deploy, but I dont 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.

1
Hi @Cataster. Based on my test, the output content is related with the msbuild argument. Please refer to my update 3 and check if it could make some changesKevin Lu-MSFT
@KevinLu-MSFT I updated the pipeline with update3 yaml, so i disabled the archive, added the MSBuild arguments as suggested, and modified pathToPublish $(build.ArtifactStagingDirectory)/$(Build.BuildId).zip -> $(build.ArtifactStagingDirectory). However, no artifact was produced this time. got the following warning: ##[warning]Directory '/home/vsts/work/1/a' is empty. Nothing will be added to build artifact 'Release'.Cataster
@KevinLu-MSFT I tested it on windows agent, and it looks like it did produce something unlike linux agent however, the path is very long. the contents are not exactly at the root. This could be why in linux agent it was not able to find anything i suppose per my comment above. so even on windows its not exactly a match with the expected artifactCataster
Could you please try to use the VS Build task to run the same arguments on Microsoft-Hosted agent? On the other hand , based on our previous discussion, you could add the /p:DeployOnBuild=true /p:PublishProfile=xxxx to the build arg to use the publish profile. Please check if it could make some changesKevin Lu-MSFT
@KevinLu-MSFT please see my updates 4 & 5Cataster

1 Answers

1
votes

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:

enter image description here

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:

enter image description here

When I add the msbuild arg, it will upload the files to the target path:

enter image description here

They have the same artifacts contents.

Update2:

You could try the following sample to create the package for Azure APP service.

Classic :

enter image description here

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:

enter image description here

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)'