Is there any way to specify a command line argument for msbuild that will apply only to one project (i.e. project-level not solution-level), when building a multi-project solution?
The reason I ask is because I want to enable side-by-side installs of a click-once deployment. Let me give an example:
1) This works
MSBuild "C:\Dev\MyProj\MyProj.Shell\MyProj.Shell.csproj" /p:SkipInvalidConfigurations=true /target:publish /p:OutputPath="C:\Dev\Temp\" /p:ApplicationVersion=1.2.3.4 /p:ProductName="My Proj" /p:Configuration="Release" /p:Platform="Mixed Platforms" /verbosity:diagnostic
2) This doesn't
MSBuild "C:\Dev\MyProj\MyProj.Shell\MyProj.Shell.csproj" /p:SkipInvalidConfigurations=true /target:publish /p:OutputPath="C:\Dev\Temp\" /p:ApplicationVersion=1.2.3.4 /p:ProductName="My Proj Test" /p:Configuration="Release" /p:Platform="Mixed Platforms" /verbosity:diagnostic /p:AssemblyName="MyProj.Test"
Just to clarify and re-iterate a couple of points:
/p:AssemblyName="MyProj.Text"
/target:publish
so this is a click-once build I know the reason why Example 2 fails is because it renames every project's AssemblyName with the assembly name passed in, i.e. MyProj.Test. This makes some sense because parameters passed in through the command line are global, but then again I'm targeting just the csproj file.
Anyway that is what happens. So is there any way to pass in a msbuild command line parameter to change just the one AssemblyName property in the MyProj.Shell.csproj file?
You can edit your project in question (its .csproj file) to obtain assembly name from a special property if it is specified, i.e.:
<AssemblyName Condition=" '$(ThisProjectNameOverrideAssemblyName)' == '' " >UsualAssemblyName</AssemblyName>
<AssemblyName Condition=" '$(ThisProjectNameOverrideAssemblyName)' != '' " >$(ThisProjectNameOverrideAssemblyName)</AssemblyName>
So when you build your project in question, you pass your ThisProjectNameOverrideAssemblyName
to override AssemblyName
for this project only:
msbuild /p:ThisProjectNameOverrideAssemblyName=NewAssemblyName
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With