If you use .NET Core CLI task to build your console app.
Below dotnet publish arguements commmand will generate .exe file. See this thread for more information.
dotnet publish -r win-x64 -p:PublishSingleFile=True --self-contained false
So you can add above arguments to your .NET Core CLI task. See below yaml pipeline.
- task: DotNetCoreCLI@2
inputs:
command: publish
arguments: -r win-x64 -p:PublishSingleFile=True --self-contained false -o $(Build.ArtifactStagingDirectory)
projects: '**/*.csproj'
publishWebProjects: false
enabled: true
Above DotNetCoreCLI task will output the .exe file to folder $(Build.ArtifactStagingDirectory)
(ie. C:\agent\_work\1\a
)
If you use Visual Studio Build task to build your console app.
You can first add below <PublishSingleFile>
and <RuntimeIdentifier>
properties to the .csproj file of your project.
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<PublishSingleFile>True</PublishSingleFile>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>
Then set the msbuildArgs of the Visual Studio Build task in your pipeline as below:
- task: VSBuild@1
inputs:
solution: '$(solution)'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
msbuildArgs: '/t:publish /p:PublishSingleFile=True /p:RuntimeIdentifier=win-x64 /p:outputpath=$(Build.ArtifactStagingDirectory)\'
Then Vsbuild task will output the .exe file to folder $(Build.ArtifactStagingDirectory)
specified in /p:outputpath
(ie. C:\agent\_work\1\a
)