Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is my build script for targeting multiple target frameworks working correctly?

I wrote a little MSBuild script to build my project on multiple versions. When I run it from VS2012 Command Prompt it works, I don't get any errors or exceptions. However when I compare the produced assemblies, they are identical. Is there something wrong in my script?

<Target Name="Build">

  <MSBuild Projects=".\WcfClientBase\WcfClientBase.csproj" 
           Properties="Configuration=Release;OutputPath=.\BuildArtifacts\net45;TargetFrameworkVersion=v4.5" />

  <MSBuild Projects=".\WcfClientBase\WcfClientBase.csproj"
           Properties="Configuration=Release;OutputPath=.\BuildArtifacts\net40;TargetFrameworkVersion=v4.0" />

  <MSBuild Projects=".\WcfClientBase\WcfClientBase.csproj"
           Properties="Configuration=Release;OutputPath=.\BuildArtifacts\net35;TargetFrameworkVersion=v3.5" />

</Target>

I have VS2012 Professional installed. I also noticed .NET 4.5 doesn't have its own MSBuild.exe. Is it using the one from version 4.0?

Update

I built it with Visual Studio for each version and all assemblies are different. There is something wrong with my script. I deliberately mistyped the TargetFrameworkVersion parameter name but it still built and produced same outputs. Maybe it's unable to override that parameter from the project file or there are other parameters I am missing. Any more ideas?

like image 675
Ufuk Hacıoğulları Avatar asked Oct 07 '22 19:10

Ufuk Hacıoğulları


1 Answers

You also need to customize IntermediateOutputPath property, otherwise all 3 flavors share the same intermediate directory obj\Release. Try this:

<Target Name="Build"> 
     <MSBuild Projects="WcfClientBase\WcfClientBase.csproj"  
         Properties="Configuration=Release;OutputPath=BuildArtifacts\net45\;IntermediateOutputPath=obj\Release\net45\;TargetFrameworkVersion=v4.5" /> 
     <MSBuild Projects="WcfClientBase\WcfClientBase.csproj"  
         Properties="Configuration=Release;OutputPath=BuildArtifacts\net40\;IntermediateOutputPath=obj\Release\net40\;TargetFrameworkVersion=v4.0" /> 
     <MSBuild Projects="WcfClientBase\WcfClientBase.csproj"  
         Properties="Configuration=Release;OutputPath=BuildArtifacts\net35\;IntermediateOutputPath=obj\Release\net35\;TargetFrameworkVersion=v3.5" /> 
 </Target> 
like image 95
seva titov Avatar answered Oct 10 '22 03:10

seva titov