0

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
  • Nitro5 can you update your question to include the error message you might be experiencing? Commented Feb 17, 2022 at 21:55
  • I found another question you posted Nitro5 with more detail in it... (stackoverflow.com/questions/71163827/…) I'm updating the question with additional info. Commented Feb 17, 2022 at 21:59

2 Answers 2

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-project\bin\'
  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.

Sign up to request clarification or add additional context in comments.

1 Comment

Locally it only puts in the bin by default because the platform/build config combo in the csproj has it set to /bin. If the platform/combo doesn't exist in the csproj, then you'll get an error locally - and in DevOps (if targeting the project). If the combo doesn't exist in the sln or csproj then the msbuild arg stated should work.
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"'

2 Comments

yes no works :(
What's the error?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.