|
67 | 67 | <ItemGroup>
|
68 | 68 | <None Include="LibSass.Net.nuspec" />
|
69 | 69 | <None Include="libsassnet.targets" />
|
| 70 | + <None Include="packages.config" /> |
70 | 71 | </ItemGroup>
|
71 | 72 | <ItemGroup>
|
72 | 73 | <Reference Include="System" />
|
73 | 74 | <Reference Include="System.Runtime.Serialization" />
|
74 | 75 | </ItemGroup>
|
75 | 76 | <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
| 77 | + <!-- Detect Platform --> |
| 78 | + <UsingTask TaskName="OSVersionInformation" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll"> |
| 79 | + <ParameterGroup> |
| 80 | + <LibSassPlatform ParameterType="System.String" Output="true" /> |
| 81 | + </ParameterGroup> |
| 82 | + <Task> |
| 83 | + <Using Namespace="System.Reflection" /> |
| 84 | + <Code Type="Fragment" Language="cs"><![CDATA[ |
| 85 | + var assembly = Assembly.LoadFrom(@"..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll"); |
| 86 | + Type runtimeType = assembly.GetType("System.Runtime.InteropServices.RuntimeInformation"); |
| 87 | + var osDescription = runtimeType.GetProperty("OSDescription") |
| 88 | + .GetValue(null, null).ToString(); |
| 89 | + var osArchitecture = runtimeType.GetProperty("OSArchitecture") |
| 90 | + .GetValue(null, null).ToString(); |
| 91 | +
|
| 92 | + if (osDescription.StartsWith("Microsoft Windows")) |
| 93 | + { |
| 94 | + if (osArchitecture == "X86") |
| 95 | + { |
| 96 | + LibSassPlatform = "Win32"; |
| 97 | + } |
| 98 | + else if (osArchitecture == "X64") |
| 99 | + { |
| 100 | + LibSassPlatform = "Win64"; |
| 101 | + } |
| 102 | + } |
| 103 | + ]]></Code> |
| 104 | + </Task> |
| 105 | + </UsingTask> |
| 106 | + <Target Name="GetOSIdentifiers" Condition=" '$(LibSassPlatform)' == '' "> |
| 107 | + <OSVersionInformation> |
| 108 | + <Output TaskParameter="LibSassPlatform" PropertyName="LibSassPlatform" /> |
| 109 | + </OSVersionInformation> |
| 110 | + </Target> |
76 | 111 | <!-- Build LibSass -->
|
77 |
| - <Target Name="AfterBuild"> |
78 |
| - <MSBuild Targets="Build" Projects="..\LibSass\win\libsass.sln" BuildInParallel="true" Properties="Configuration=$(Configuration);Platform=Win32;TargetName=libsass32;OutDir=$(OutputPath);IntDir=$(IntermediateOutputPath)" /> |
79 |
| - <MSBuild Targets="Build" Projects="..\LibSass\win\libsass.sln" BuildInParallel="true" Properties="Configuration=$(Configuration);Platform=Win64;TargetName=libsass64;OutDir=$(OutputPath);IntDir=$(IntermediateOutputPath)" /> |
| 112 | + <Target Name="AfterBuild" DependsOnTargets="GetOSIdentifiers"> |
| 113 | + <Message Text="Commencing build for platform: $(LibSassPlatform)" /> |
| 114 | + |
| 115 | + <!-- Windows --> |
| 116 | + <MSBuild Projects="..\LibSass\win\libsass.sln" BuildInParallel="true" |
| 117 | + Condition="'$(LibSassPlatform)' == 'Win32' or '$(LibSassPlatform)' == 'Win64'" |
| 118 | + Properties="Configuration=$(Configuration);Platform=$(LibSassPlatform);OutDir=$(OutputPath);IntDir=$(IntermediateOutputPath)" /> |
80 | 119 | </Target>
|
81 | 120 | </Project>
|
0 commit comments