Skip to content

Commit 1ef403f

Browse files
kzujonpryor
authored andcommitted
[Xamarin.Android.Build.Tasks] Set TargetFrameworkRootPath in props (dotnet#573)
Always set `$(TargetFrameworkRootPath)` in props as well as `$(FrameworkPathOverride)`, as this allows users to override the value if they choose to. Also, if `$(TargetFrameworkRootPath)` isn't set by us, it's not set in the project evaluation phase, so by the time we set `$(FrameworkPathOverride)` it's still empty and wrong for Visual Studio 2013/2015. The newly added `Xamarin.Android.Sdk.targets` also allows us to add the global targets override `Xamarin.Sdk.targets` to be consistent with the `Xamarin.Sdk.props` file that we already import. This allows IDEs to provide additional behavior as needed that is cross-cutting across all Xamarin builds.
1 parent c0ad008 commit 1ef403f

File tree

4 files changed

+56
-4
lines changed

4 files changed

+56
-4
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!--
2+
***********************************************************************************************
3+
Xamarin.Android.Bindings.Before.targets
4+
5+
WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
6+
created a backup copy. Incorrect changes to this file will make it
7+
impossible to load or build your projects from the command-line or the IDE.
8+
9+
Copyright (C) 2014 Xamarin. All rights reserved.
10+
***********************************************************************************************
11+
-->
12+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
13+
14+
<!-- Allows providing SDK-specific targets overrides -->
15+
<PropertyGroup>
16+
<XamarinAndroidSdkTargets>$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), 'Xamarin.Android.Sdk.targets'))\Xamarin.Android.Sdk.targets</XamarinAndroidSdkTargets>
17+
</PropertyGroup>
18+
<Import Project="$(XamarinAndroidSdkTargets)" Condition="'$(XamarinAndroidSdkTargetsImported)' != 'true' And Exists('$(XamarinAndroidSdkTargets)')"/>
19+
20+
</Project>

src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Common.After.targets

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,10 @@ Copyright (C) 2014 Xamarin. All rights reserved.
1414
<Import Project="$(MSBuildThisFileDirectory)\Xamarin.Android.Common\ImportAfter\*"
1515
Condition="Exists('$(MSBuildThisFileDirectory)\Xamarin.Android.Common\ImportAfter')"/>
1616

17+
<!-- Allows providing SDK-specific targets overrides -->
18+
<PropertyGroup>
19+
<XamarinAndroidSdkTargets>$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), 'Xamarin.Android.Sdk.targets'))\Xamarin.Android.Sdk.targets</XamarinAndroidSdkTargets>
20+
</PropertyGroup>
21+
<Import Project="$(XamarinAndroidSdkTargets)" Condition="'$(XamarinAndroidSdkTargetsImported)' != 'true' And Exists('$(XamarinAndroidSdkTargets)')"/>
22+
1723
</Project>

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ Copyright (C) 2011-2016 Xamarin. All rights reserved.
1919
<VsInstallationID>$(DevEnvIni.Substring($(InstallationIDEqualsIndex), 8))</VsInstallationID>
2020
</PropertyGroup>
2121

22-
<PropertyGroup Condition="'$(VsInstallRoot)' != ''">
22+
<PropertyGroup>
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 Condition="'$(TargetFrameworkRootPath)' == ''">$(VsInstallRoot)\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\</TargetFrameworkRootPath>
25+
<TargetFrameworkRootPath Condition="'$(VsInstallRoot)' != '' And '$(TargetFrameworkRootPath)' == ''">$(VsInstallRoot)\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\</TargetFrameworkRootPath>
26+
<TargetFrameworkRootPath Condition="'$(VsInstallRoot)' == '' And '$(TargetFrameworkRootPath)' == ''">$(ProgramFiles)\Reference Assemblies\Microsoft\Framework\</TargetFrameworkRootPath>
27+
28+
<!-- We should always override the framework path so that XA resolves to its own mscorlib.dll -->
2629
<FrameworkPathOverride>$(TargetFrameworkRootPath)MonoAndroid\v1.0</FrameworkPathOverride>
27-
<XamarinAndroidSdkPropsImported>true</XamarinAndroidSdkPropsImported>
2830
</PropertyGroup>
2931

3032
<Target Name="RedirectMonoAndroidSdkPaths" Condition="'$(VsInstallRoot)' != ''">
@@ -53,6 +55,10 @@ Copyright (C) 2011-2016 Xamarin. All rights reserved.
5355
</Task>
5456
</UsingTask>
5557

58+
<PropertyGroup>
59+
<XamarinAndroidSdkPropsImported>true</XamarinAndroidSdkPropsImported>
60+
</PropertyGroup>
61+
5662
<!-- Allows providing Xamarin SDK-specific property overrides -->
5763
<Import Project="Xamarin.Sdk.props" Condition="'$(XamarinSdkPropsImported)' != 'true' And Exists('Xamarin.Sdk.props')"/>
58-
</Project>
64+
</Project>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!--
2+
***********************************************************************************************
3+
Xamarin.Android.Sdk.targets
4+
5+
WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
6+
created a backup copy. Incorrect changes to this file will make it
7+
impossible to load or build your projects from the command-line or the IDE.
8+
9+
Copyright (C) 2011-2016 Xamarin. All rights reserved.
10+
***********************************************************************************************
11+
-->
12+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
13+
14+
<PropertyGroup>
15+
<XamarinAndroidSdkTargetsImported>true</XamarinAndroidSdkTargetsImported>
16+
</PropertyGroup>
17+
18+
<!-- Allows providing Xamarin SDK-specific targets overrides -->
19+
<Import Project="Xamarin.Sdk.targets" Condition="'$(XamarinSdkTargetsImported)' != 'true' And Exists('Xamarin.Sdk.targets')"/>
20+
</Project>

0 commit comments

Comments
 (0)