Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set publishName/AssemblyName in msbuild command line parameters?

Tags:

c#

msbuild

There are two names for the application that you are publishing, the productName and the publishName (publishName/AssemblyName I think they are the same). Both of which you can specify in your .csproj file.

I want to set both of these without changing the .csproj file using MSBuild's command line parameters. So far I have used this page from msdn and figured out how to change the product name.

MSBuild.exe /t:Build /p:ProductName=$productName. 

How can I change the publishName in a similar fashion?

When I say publishName I mean the file that gets created with the .application extension. Anyone know what property I need for this - /p:*?

I have also checked out a Stack Overflow page and tried all of the suggestions there but they didn't work.

like image 272
jgerstle Avatar asked Jan 15 '13 16:01

jgerstle


2 Answers

To solve this, I added my own variable in the .csproj file to control the name of the .exe (without affecting the name of the subproject builds):

<!-- Make the assembly name configurable -->
<AssemblyName Condition=" '$(MSBuildAssemblyName)' == '' ">MyDefaultAssemblyName</AssemblyName>
<AssemblyName Condition=" '$(MSBuildAssemblyName)' != '' ">$(MSBuildAssemblyName)</AssemblyName>

if MSBuildAssemblyName is not specified on the command line, it uses the default name (MyDefaultAssemblyName).

On the command line, invoke it like this: msbuild ... /p:MSBuildAssemblyName=MyOverriddenName ...

like image 53
AtliB Avatar answered Oct 11 '22 08:10

AtliB


Don't include the quotation marks!

MSBuild.exe /t:Build /p:ProductName=$productName;AssemblyName=yourNameHere

Also, this won't work if you have another project in the same solution - both will get the same assembly name!

like image 35
James Joyce Avatar answered Oct 11 '22 09:10

James Joyce