skip to Main Content

I have the following task:

  - task: DotNetCoreCLI@2
    inputs:
      command: 'build'
      projects: 'XXX'
      arguments: '-c "Release" /p:Platform="x64"'

and I want to set the outputpath of the build so that I can publish an artifact after compiling.

    /p:OutputPath="$(build.artifactStagingDirectory)XXX"

But when I specify the output directory (–output $(Build.ArtifactStagingDirectory)X’) I get an error MSB3073

If I remove the output argument it works.

How can I build correctly so that I can publish the artifact or solve the output issue?

2

Answers


  1. Have you tried adding it to the arguments?

      - task: DotNetCoreCLI@2
        inputs:
          command: 'build'
          projects: 'XXX'
          arguments: '-c "Release" /p:Platform="x64" /p:OutputPath="$(build.artifactStagingDirectory)XXX"'
    
    Login or Signup to reply.
  2. If you don’t specify the output directory when compiling, the project will compile and place the bin folder in the subfolder of the project. This is the same behavior if you were to compile the solution locally. So you could publish the artifact from that folder:

    - publish: '$(Build.SourcesDirectory)path-to-my-projectbin'
      artifact: myArtifact
    

    For .NET core projects, the command syntax for dotnet build is:

    dotnet build [options] <project | solution>
    

    The syntax for the output directory is -o <directory> or --output <directory>. The important detail here is you need to wrap the output directory in quotes and additional msbuild parameters are specified as -p:<param>="value"

    Fun tip, you can use the > operator in YAML to represent multi-line strings, so you could represent your task this way:

    - task: DotNetCoreCLI@2
      inputs:
        command: 'build'
        projects: 'XXX'
        arguments: >
          -c "Release"
          -p:Platform="x64"
          -o "$(Build.artifactStagingDirectory)XXX"
    

    Also note, this being .NET Core, if you’re using a Linux build agent, you’ll need to use backslashes (‘/’) for the file path.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search