4

I created a pipeline using the .NET desktop template and using the 'create .msi' extension but it shows a warning:

 ##[warning]No .MSI files were found, please check your build-configuration. If this is expected, you might consider to use the default Visual Studio Build task instead of this custom Installer task.
2018-11-28T22:58:54.1434410Z ##[section]Finishing: Create .msi file(s) from VS Installer project(s).

Anyone know how can I achieve creating an exe file using an Azure Pipeline and deploy it on a Virtual Machine.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
rahul sahu
  • 51
  • 1
  • 1
  • 2
  • Have you checked [Build your .NET desktop app for Windows](https://learn.microsoft.com/en-us/azure/devops/pipelines/apps/windows/dot-net?view=azure-devops&tabs=vsts) or [Create a CI/CD pipeline for .NET with the Azure DevOps Project](https://www.azuredevopslabs.com/labs/vstsextend/azuredevopsprojectdotnet/)? – rickvdbosch Jun 11 '20 at 06:56
  • @rickvdbosch yes but I want to create exe(setup) file using azure pipeline ? – rahul sahu Jun 11 '20 at 07:29
  • An `.exe` and a setup file are not the same. An `.exe` is an executable file, the program to run. A setup is only needed if you want to distribute this program for instance over the internet and you think a zip won't cut it. For you to publish this application to a VM is as easy as copying the output folder to the VM. Tip: start with a pipeline that successfully builds the executable and then take the next step. – rickvdbosch Jun 11 '20 at 07:33
  • @rickvdbosch sir which step I need to follow can you explain me because pipeline is run but .exe file is not create and I need to create .exe and run on VM. – rahul sahu Jun 11 '20 at 08:46
  • @rickvdbosch I also try to copy that artifacts to VM and artifacts are copied but I am uable to run application on that vm its show missing some dependencies files..i don't know why – rahul sahu Jun 11 '20 at 08:53

1 Answers1

14

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)

Levi Lu-MSFT
  • 27,483
  • 2
  • 31
  • 43