Skip to content

Commit 00334a0

Browse files
committed
[msbuild] Preserve overriden values and only override on VS2017+
Since we now have the Sdk imports in VS2013/15 too, we need to also detect VsInstallRoot before overriding the framework paths. Also, if alternative values have already been provided, we should not override them (i.e. CI where the location is != than the VS install location, etc.) (CP from xamarin/XamarinVS@a2a4958)
1 parent 69d1473 commit 00334a0

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Xamarin.Android.Sdk.props

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,23 @@ Copyright (C) 2011-2016 Xamarin. All rights reserved.
1111
-->
1212
<Project InitialTargets="RedirectMonoAndroidSdkPaths;RemoveSdksCache" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
1313

14-
<PropertyGroup>
14+
<PropertyGroup Condition="'$(VsInstallRoot)' != ''">
1515
<!-- Grab InstallationID from devenv.ini.isolation's InstallationID=[ID] -->
1616
<DevEnvIni>$([System.IO.File]::ReadAllText('$(VsInstallRoot)\Common7\IDE\devenv.isolation.ini'))</DevEnvIni>
1717
<InstallationIDEqualsIndex>$(DevEnvIni.IndexOf('InstallationID='))</InstallationIDEqualsIndex>
1818
<InstallationIDEqualsIndex>$([MSBuild]::Add('$(InstallationIDEqualsIndex)', '15'))</InstallationIDEqualsIndex>
1919
<VsInstallationID>$(DevEnvIni.Substring($(InstallationIDEqualsIndex), 8))</VsInstallationID>
2020
</PropertyGroup>
2121

22-
<PropertyGroup>
22+
<PropertyGroup Condition="'$(VsInstallRoot)' != ''">
2323
<!-- Until VS2017+ includes its own ReferenceAssemblies outside of C:\Program Files (x86)\Reference Assemblies and into
2424
the VsInstallRoot, we must override this ourselves for our SDKs -->
25-
<TargetFrameworkRootPath>$(VsInstallRoot)\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\</TargetFrameworkRootPath>
26-
<FrameworkPathOverride>$(TargetFrameworkRootPath)MonoAndroid\v1.0</FrameworkPathOverride>
25+
<TargetFrameworkRootPath Condition="'$(TargetFrameworkRootPath)' == ''">$(VsInstallRoot)\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\</TargetFrameworkRootPath>
26+
<FrameworkPathOverride Condition="'$(FrameworkPathOverride)' == ''">$(TargetFrameworkRootPath)MonoAndroid\v1.0</FrameworkPathOverride>
2727
<XamarinAndroidSdkPropsImported>true</XamarinAndroidSdkPropsImported>
2828
</PropertyGroup>
2929

30-
<Target Name="RedirectMonoAndroidSdkPaths">
30+
<Target Name="RedirectMonoAndroidSdkPaths" Condition="'$(VsInstallRoot)' != ''">
3131
<PropertyGroup>
3232
<MonoAndroidToolsDirectory Condition=" '$(MonoAndroidToolsDirectory)' == '' ">$(VsInstallRoot)\MSBuild\Xamarin\Android</MonoAndroidToolsDirectory>
3333
<MonoAndroidBinDirectory Condition=" '$(MonoAndroidBinDirectory)' == '' ">$(VsInstallRoot)\MSBuild\Xamarin\Android</MonoAndroidBinDirectory>
@@ -40,7 +40,7 @@ Copyright (C) 2011-2016 Xamarin. All rights reserved.
4040
<Delete Files="$(IntermediateOutputPath)sdks.cache" />
4141
</Target>
4242

43-
<UsingTask TaskName="SetVsMonoAndroidRegistryKey" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
43+
<UsingTask Condition="'$(VsInstallRoot)' != ''" TaskName="SetVsMonoAndroidRegistryKey" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
4444
<ParameterGroup>
4545
<InstallationID Required="true" />
4646
<VisualStudioVersion Required="true" />

0 commit comments

Comments
 (0)