I am trying to configure an MSBuild target, in my Project.csproj file. The target, called "Test" is called with the following command:
msbuild.exe /target:Test
However, I cannot figure out how to change the AssemblyName (original assembly name is MyProject), for this target. My code looks like this:
<Target Name="Test">
<PropertyGroup>
<PublishUrl>D:\PublishLocation\ClickOnce Setup\</PublishUrl>
</PropertyGroup>
<MSBuild Projects="$(ProjLocation)\$(ProjectName).csproj" Properties="ProductName=$(ProductName) (Test); AssemblyName=MyProjectTest; PublishUrl=$(PublishUrl)" Targets="Publish" />
<ItemGroup>
<SetupFiles Include="$(ProjPublishLocation)\*.*" />
<UpdateFiles Include="$(ProjPublishLocation)\Application Files\**\*.*" />
</ItemGroup>
<Copy SourceFiles="@(SetupFiles)" DestinationFolder="D:\PublishLocation\ClickOnce Setup\" />
<Copy SourceFiles="@(UpdateFiles)" DestinationFolder="D:\PublishLocation\ClickOnce Setup\Application Files\%(RecursiveDir)" />
</Target>
If I remove the AssemblyName=MyProjectTest;
from the code, it works fine. If I run it as above, I get the following error:
"C:\Users\...\MyProject\MyProject.csproj" (Test target) (1) -> "C:\Users\...\MyProject\MyProject.csproj" (Publish target) (1:2 ) ->
(CoreCompile target) ->
Models\SessionModel.cs(207,51): error CS1528: Expected ; or = (cannot specify constructor arguments in declaration) [ C:\Users\...\MyProject\MyProject.csproj](...and a lot more, which is more or less the same)
UPDATE
I found some more, perhaps more interesting, warnings in the build output:
"C:\Users\...\MyProject\MyProject.csproj" (Fast target) (1) -> "C:\Users\...\MyProject.csproj" (Publish target) (1:2 ) -> (ResolveAssemblyReferences target) ->
C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1820,5): warning MSB3277: Found conflicts between different versions of the same dependent assembly that could not be resolved. These reference conflicts a re listed in the build log when log verbosity is set to detailed. [C:\Users\...\MyProject\MyProject.csproj]
It might be worth mentioning, that I have older versions published in the publish location, in which the assembly name was not changed. Can this cause the conflict I see...?