Fix dotnet-build.sh
[platform/core/dotnet/build-tools.git] / dotnet / sdk / 2.0.0-preview1-005977 / Sdks / Microsoft.NET.Sdk / build / Microsoft.NET.RuntimeIdentifierInference.targets
1 <!--\r
2 ***********************************************************************************************\r
3 Microsoft.NET.RuntimeIdentifierInference.targets\r
4 \r
5 WARNING:  DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have\r
6           created a backup copy.  Incorrect changes to this file will make it\r
7           impossible to load or build your projects from the command-line or the IDE.\r
8 \r
9 Copyright (c) .NET Foundation. All rights reserved. \r
10 ***********************************************************************************************\r
11 -->\r
12 <Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
13 \r
14   <PropertyGroup>\r
15     <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>\r
16   </PropertyGroup>\r
17 \r
18   <!--\r
19     .NETFramework cannot load native package dependencies dynamically\r
20     based on the current architecture.  We have must have a RID to\r
21     resolve and copy native dependencies to the output directory.\r
22 \r
23      When building a .NETFramework exe on Windows and not given a RID,\r
24      we'll pick either win7-x64 or win7-x86 (based on PlatformTarget)\r
25      if we're not given an explicit RID. However, if after resolving\r
26      NuGet assets we find no copy-local native dependencies, we will\r
27      emit the binary as AnyCPU.\r
28 \r
29      Note that we must set the RID here early (to be seen during NuGet\r
30      restore) in order for the project.assets.json to include the\r
31      native dependencies that will let us make the final call on\r
32      AnyCPU or platform-specific.\r
33 \r
34      This allows these common cases to work without requiring mention\r
35      of RuntimeIdentifier in the user project PlatformTarget:\r
36 \r
37       1. Building an AnyCPU .NETFramework application on any host OS\r
38          with no native NuGet dependencies. (*)\r
39 \r
40       2. Building an x86 or x64 NETFramework application on and for\r
41          Windows with native NuGet dependencies that do not require\r
42          greater than win7.\r
43 \r
44      However, any other combination of host operating system, CPU\r
45      architecture, and minimum Windows version will require some\r
46      manual intervention in the project file to set up the right\r
47      RID. (**)\r
48 \r
49      (*) Building NET4x from non-Windows is still not fully supported:\r
50          https://github.com/dotnet/sdk/issues/335) The point above is\r
51          that this code would not have to change to make the first\r
52          scenario work on non-Windows hosts.\r
53 \r
54      (**) https://github.com/dotnet/sdk/issues/840 tracks improving\r
55           the default RID selection here to make more non-AnyCPU scenarios\r
56           work without user intervention. The current static evaluation\r
57           requirement limits us.\r
58    -->\r
59   <PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework' and \r
60                             '$(OutputType)' == 'Exe' and \r
61                             '$(OS)' == 'Windows_NT' and\r
62                             '$(RuntimeIdentifier)' == ''">\r
63     <_UsingDefaultRuntimeIdentifier>true</_UsingDefaultRuntimeIdentifier>\r
64     <RuntimeIdentifier Condition="'$(PlatformTarget)' == 'x64'">win7-x64</RuntimeIdentifier>\r
65     <RuntimeIdentifier Condition="'$(PlatformTarget)' == 'x86' or '$(PlatformTarget)' == ''">win7-x86</RuntimeIdentifier>\r
66   </PropertyGroup>\r
67 \r
68   <PropertyGroup Condition="'$(PlatformTarget)' == ''">\r
69     <_UsingDefaultPlatformTarget>true</_UsingDefaultPlatformTarget>\r
70   </PropertyGroup>\r
71 \r
72   <!-- Determine PlatformTarget (if not already set) from runtime identifier. -->\r
73   <Choose>\r
74     <When Condition="'$(PlatformTarget)' != '' or '$(RuntimeIdentifier)' == ''" />\r
75 \r
76     <When Condition="$(RuntimeIdentifier.EndsWith('-x86')) or $(RuntimeIdentifier.Contains('-x86-'))">\r
77       <PropertyGroup>\r
78         <PlatformTarget>x86</PlatformTarget>\r
79       </PropertyGroup>\r
80     </When>\r
81 \r
82     <When Condition="$(RuntimeIdentifier.EndsWith('-x64')) or $(RuntimeIdentifier.Contains('-x64-'))">\r
83       <PropertyGroup>\r
84         <PlatformTarget>x64</PlatformTarget>\r
85       </PropertyGroup>\r
86     </When>\r
87 \r
88     <When Condition="$(RuntimeIdentifier.EndsWith('-arm')) or $(RuntimeIdentifier.Contains('-arm-'))">\r
89       <PropertyGroup>\r
90         <PlatformTarget>arm</PlatformTarget>\r
91       </PropertyGroup>\r
92     </When>\r
93 \r
94     <!-- NOTE: PlatformTarget=arm64 is not currently supported and therefore no inference of that here. -->\r
95     <Otherwise>\r
96       <PropertyGroup>\r
97         <PlatformTarget>AnyCPU</PlatformTarget>\r
98       </PropertyGroup>\r
99     </Otherwise>\r
100   </Choose>\r
101 \r
102   <!--\r
103     SelfContained was not an option in .NET Core SDK 1.0. \r
104     Default SelfContained based on the RuntimeIdentifier, so projects don't have to explicitly set SelfContained.\r
105     This avoids a breaking change from 1.0 behavior.\r
106     -->\r
107   <PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and '$(OutputType)' == 'Exe' and '$(SelfContained)' == ''">\r
108     <SelfContained Condition="'$(RuntimeIdentifier)' == ''">false</SelfContained>\r
109     <SelfContained Condition="'$(RuntimeIdentifier)' != ''">true</SelfContained>\r
110   </PropertyGroup>\r
111 \r
112   <Target Name="_CheckForUnsupportedSelfContained"\r
113           BeforeTargets="_CheckForInvalidConfigurationAndPlatform"\r
114           Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and '$(OutputType)' == 'Exe'">\r
115     \r
116     <NETSdkError Condition="'$(SelfContained)' == 'true' and '$(RuntimeIdentifier)' == ''"\r
117                  ResourceName="CannotHaveSelfContainedWithoutRuntimeIdentifier" />\r
118     \r
119   </Target>\r
120 \r
121   <PropertyGroup>\r
122     <!-- Projects can opt out of having the RID appended to the output path by setting this to false. -->\r
123     <AppendRuntimeIdentifierToOutputPath Condition="'$(AppendRuntimeIdentifierToOutputPath)' == ''">true</AppendRuntimeIdentifierToOutputPath>\r
124   </PropertyGroup>\r
125 \r
126   <!--\r
127     Append $(RuntimeIdentifier) directory to output and intermediate paths to prevent bin clashes between\r
128     targets. \r
129 \r
130     But do not append the implicit default runtime identifier for .NET Framework apps as that would \r
131     append a RID the user never mentioned in the path and do so even in the AnyCPU case.\r
132    -->\r
133   <PropertyGroup Condition="'$(AppendRuntimeIdentifierToOutputPath)' == 'true' and '$(RuntimeIdentifier)' != '' and '$(_UsingDefaultRuntimeIdentifier)' != 'true'">\r
134     <IntermediateOutputPath>$(IntermediateOutputPath)$(RuntimeIdentifier)\</IntermediateOutputPath>\r
135     <OutputPath>$(OutputPath)$(RuntimeIdentifier)\</OutputPath>\r
136   </PropertyGroup>\r
137 \r
138   <!-- \r
139     Switch our default .NETFramework CPU architecture choice back to AnyCPU before \r
140     compiling the exe if no copy-local native dependencies were resolved from NuGet \r
141   -->\r
142   <Target Name="AdjustDefaultPlatformTargetForNetFrameworkExeWithNoNativeCopyLocalItems"\r
143           AfterTargets="ResolvePackageDependenciesForBuild"\r
144           BeforeTargets="CoreCompile"\r
145           Condition="'$(_UsingDefaultPlatformTarget)' == 'true' and\r
146                      '$(_UsingDefaultRuntimeIdentifier)' == 'true' and \r
147                      '@(NativeCopyLocalItems)' == ''">\r
148     <PropertyGroup>\r
149       <PlatformTarget>AnyCPU</PlatformTarget>\r
150     </PropertyGroup>\r
151   </Target>\r
152 \r
153 </Project>\r