[csproj] Update generator to handle platform-specific assemblies (#4847)
authorAlexander Köplinger <alex.koeplinger@outlook.com>
Sat, 13 May 2017 15:26:35 +0000 (17:26 +0200)
committerGitHub <noreply@github.com>
Sat, 13 May 2017 15:26:35 +0000 (17:26 +0200)
After https://github.com/mono/mono/pull/4837 was merged the
csproj update bot started sending PRs which hardcoded net_4_x-linux
as the OutputPath.

Updated the csproj generator to detect this and use a variable
in the OutputPath instead. It'll autodetect based on the current OS
and can be overriden by passing /p:HostPlatform=foobar to msbuild.

Ideally we'd have configurations for each platform in the csproj since
in the future the file lists will be different but this is a first step.

mcs/.gitignore
msvc/scripts/csproj.tmpl
msvc/scripts/genproj.cs

index ac21fbc31e58122816e8f9194fdf215b1cba8d95..03dd16548201ae5066021be393baf30bcd5d129e 100644 (file)
@@ -21,7 +21,7 @@ class/RabbitMQ.Client/docs/specs/autogenerated-api-qpid-0-8.cs
 class/System.Web.Mvc/System.Web.Mvc/Resources/MvcResources.resources
 class/System.Web.Mvc2/System.Web.Mvc/Resources/MvcResources.resources
 XmlWriter
-obj-net_4_x
+obj-net_4_x*
 obj-bare
 obj-plainweb
 obj-Facades
@@ -30,3 +30,4 @@ obj-plaindesign
 obj-plainservice
 obj-secxml
 obj-mcs-net_4_x
+obj-legacy
index 4c7e1dba13730b023206ef8b0b1da39c9aced209..1b2e850e5e3330287beaf5c14cbcf1efaf54ff79 100644 (file)
@@ -9,6 +9,9 @@
     <ProjectGuid>@PROJECTGUID@</ProjectGuid>\r
     <OutputType>@OUTPUTTYPE@</OutputType>\r
     <NoWarn>@DISABLEDWARNINGS@</NoWarn>\r
+    <HostPlatform Condition=" '$(HostPlatform)' == '' and '$(OS)' == 'Windows_NT'">win32</HostPlatform>\r
+    <HostPlatform Condition=" '$(HostPlatform)' == '' and '$(OS)' == 'Unix' and $([System.IO.File]::Exists('/usr/lib/libc.dylib'))">darwin</HostPlatform>\r
+    <HostPlatform Condition=" '$(HostPlatform)' == '' and '$(OS)' == 'Unix'">linux</HostPlatform>\r
     <OutputPath>@OUTPUTDIR@</OutputPath>\r
     <IntermediateOutputPath>obj-@OUTPUTSUFFIX@</IntermediateOutputPath>\r
     <GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>\r
index bf450539688c65b76e790b6beae92a2971d2f91d..378d1c00db7210c098bc3bd9b84f275633f77e4b 100644 (file)
@@ -900,6 +900,12 @@ class MsbuildGenerator {
                else
                        build_output_dir = "bin\\Debug\\" + library;
 
+               if (build_output_dir.Contains ("-linux") || build_output_dir.Contains ("-darwin") || build_output_dir.Contains ("-win32"))
+                       build_output_dir = build_output_dir
+                               .Replace ("-linux", "-$(HostPlatform)")
+                               .Replace ("-darwin", "-$(HostPlatform)")
+                               .Replace ("-win32", "-$(HostPlatform)");
+
                bool basic_or_build = (library.Contains ("-basic") || library.Contains ("-build"));
 
                //