Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configure MSBuild output path

Tags:

There is a Windows Forms (NET 3.5) project, foo.csproj, with localized resources files. I use MSBuild to build the project and create a deployment structure:

<MSBuild Projects="foo.csproj" Properties="Configuration=Release;OutputPath=..\deploy\foo" Targets="Build" /> 

It copies foo.exe and all localized DLL files to the deploy\foo folder, but I need localized DLL files to be copied into a separate folder. It should be:

  • deploy\foo\foo.exe
  • deploy\locales\ru-RU\foo.resources.dll
  • deploy\locales\pt-BR\foo.resources.dll

Is there a way to configure MSBuild to copy EXE and DLL files to different folders?

like image 811
wince Avatar asked Oct 28 '13 11:10

wince


People also ask

How do you create an output path?

Right-click on the project node in Solution Explorer and select Properties. Expand the Build section, and select the Output subsection. Find the Base output path for C#, and type in the path to generate output to (absolute or relative to the root project directory), or choose Browse to browse to that folder instead.

How do I find MSBuild path?

For example, the path to MSBuild.exe installed with Visual Studio 2019 Community is C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe You can also use the following PowerShell module to locate MSBuild: vssetup. powershell.

How do I set properties in MSBuild?

MSBuild lets you set properties on the command line by using the -property (or -p) switch. These global property values override property values that are set in the project file. This includes environment properties, but does not include reserved properties, which cannot be changed.


1 Answers

Using MSBuild command line, you can specify the output path like below:

C:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild.exe <path_to_project_file> /t:Build /p:OutDir=c:\custom_build_out\;Configuration=PRODUCTION;Platform=x64 

Note:

  1. If you change the order of specifying the OutDir property for /p, this doesn't work.
  2. The OutDir property is for specifying a full path to an alternate directory. OutputPath is for a relative directory.
  3. It has to have a project name + build configuration name in the custom build output path as MSBuild does not append these things to the OutDir.
like image 109
Jerome Anthony Avatar answered Sep 22 '22 09:09

Jerome Anthony