How to publish .NET "Release" artifact?

Cataster

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.

Kevin Lu-MSFT

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to publish artifact into Azure Artifact

Azure release pipeline for Spring Boot app says it has no artifact to publish

Release is triggered even though build does not publish artifact

How to publish docker image as an artifact in azure devops

How to publish an Android library as a Maven artifact on Bitbucket?

How to publish proguard JAR as Maven Artifact using Gradle Publish Plugin

How to publish specific files using Publish Build Artifact Task

How to release automatically your artifact to GitHub

How to detect release/snapshot versioning of maven artifact?

Publish latest build artifact from "LOCAL" Jenkins to Azure DevOps Release Pipeline?

Maven release plugin - how to publish only a snapshot?

How to use artifactoryPublish to publish release and debug artifacts

How do I publish the artifact generated from assemblyPackageDependency

How do Publish Build and Artifact to Artifactory using JFrog CLI?

How to exclude node_modules folder from publish artifact in VSTS

Gradle: How do I publish a custom file artifact?

How to publish additional artifact with sbt (one-jar)

TFS online Publish artifact

How to link subfolder in version control as artifact in release management

How to read directory path of the Artifact in Release pipeline in Azure DevOps?

Release a SQL artifact in Maven

Appveyor release artifact not detected

Azure release add artifact

Azure Pipeline Publish Artifact - Artifact Name

Publish gradle artifact whitout source

Publish Artifact with <scope>test</scope>

failed to publish artifact with JFrog CLI

How to publish in MavenCentral a build variant different than "release"

How to publish Travis CI artifacts to GitHub Release from several jobs