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
Have you tried adding it to the
arguments
?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:For .NET core projects, the command syntax for dotnet build is:
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:Also note, this being .NET Core, if you’re using a Linux build agent, you’ll need to use backslashes (‘/’) for the file path.