9

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.

3 Answers 3

11

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 ...

Sign up to request clarification or add additional context in comments.

2 Comments

I can't guarantee that this is the right answer as it was published so long after the original question and I no longer work in C#, but it looks right, so I will mark it as the answer
Still working for me!
4

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!

Comments

0

Try the following:

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

This was taken from the MSBuild Command-Line Reference.

2 Comments

That prevented me from being able to publish
I got a lot of these (this works when I don't use that assembly name parameter you suggested, which btw I looked at that link and I don't see what you are talking about it doesn't seem to list that as a valid parameter): C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(4264,5): error MSB3073: The command "xcopy .dll <path to bin folder> /kqry" exited with code 4. [.csproj]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.