blob: 2a2f1303170f66ad0254430b30ed8cd753c6a2cd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
|
<!--
***********************************************************************************************
Microsoft.NET.RuntimeIdentifierInference.targets
WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
created a backup copy. Incorrect changes to this file will make it
impossible to load or build your projects from the command-line or the IDE.
Copyright (c) .NET Foundation. All rights reserved.
***********************************************************************************************
-->
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--
.NETFramework cannot load native package dependencies dynamically
based on the current architecture. We have must have a RID to
resolve and copy native dependencies to the output directory.
When building a .NETFramework exe on Windows and not given a RID,
we'll pick either win7-x64 or win7-x86 (based on PlatformTarget)
if we're not given an explicit RID. However, if after resolving
NuGet assets we find no copy-local native dependencies, we will
emit the binary as AnyCPU.
Note that we must set the RID here early (to be seen during NuGet
restore) in order for the project.assets.json to include the
native dependencies that will let us make the final call on
AnyCPU or platform-specific.
This allows these common cases to work without requiring mention
of RuntimeIdentifier in the user project PlatformTarget:
1. Building an AnyCPU .NETFramework application on any host OS
with no native NuGet dependencies. (*)
2. Building an x86 or x64 NETFramework application on and for
Windows with native NuGet dependencies that do not require
greater than win7.
However, any other combination of host operating system, CPU
architecture, and minimum Windows version will require some
manual intervention in the project file to set up the right
RID. (**)
(*) Building NET4x from non-Windows is still not fully supported:
https://github.com/dotnet/sdk/issues/335) The point above is
that this code would not have to change to make the first
scenario work on non-Windows hosts.
(**) https://github.com/dotnet/sdk/issues/840 tracks improving
the default RID selection here to make more non-AnyCPU scenarios
work without user intervention. The current static evaluation
requirement limits us.
-->
<PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework' and
'$(HasRuntimeOutput)' == 'true' and
'$(OS)' == 'Windows_NT' and
'$(RuntimeIdentifier)' == ''">
<_UsingDefaultRuntimeIdentifier>true</_UsingDefaultRuntimeIdentifier>
<RuntimeIdentifier Condition="'$(PlatformTarget)' == 'x64'">win7-x64</RuntimeIdentifier>
<RuntimeIdentifier Condition="'$(PlatformTarget)' == 'x86' or '$(PlatformTarget)' == ''">win7-x86</RuntimeIdentifier>
</PropertyGroup>
<PropertyGroup Condition="'$(PlatformTarget)' == ''">
<_UsingDefaultPlatformTarget>true</_UsingDefaultPlatformTarget>
</PropertyGroup>
<!-- Determine PlatformTarget (if not already set) from runtime identifier. -->
<Choose>
<When Condition="'$(PlatformTarget)' != '' or '$(RuntimeIdentifier)' == ''" />
<When Condition="$(RuntimeIdentifier.EndsWith('-x86')) or $(RuntimeIdentifier.Contains('-x86-'))">
<PropertyGroup>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
</When>
<When Condition="$(RuntimeIdentifier.EndsWith('-x64')) or $(RuntimeIdentifier.Contains('-x64-'))">
<PropertyGroup>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
</When>
<When Condition="$(RuntimeIdentifier.EndsWith('-arm')) or $(RuntimeIdentifier.Contains('-arm-'))">
<PropertyGroup>
<PlatformTarget>arm</PlatformTarget>
</PropertyGroup>
</When>
<!-- NOTE: PlatformTarget=arm64 is not currently supported and therefore no inference of that here. -->
<Otherwise>
<PropertyGroup>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
</Otherwise>
</Choose>
<!--
SelfContained was not an option in .NET Core SDK 1.0.
Default SelfContained based on the RuntimeIdentifier, so projects don't have to explicitly set SelfContained.
This avoids a breaking change from 1.0 behavior.
-->
<PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and '$(HasRuntimeOutput)' == 'true'">
<SelfContained Condition="'$(SelfContained)' == '' and '$(RuntimeIdentifier)' != ''">true</SelfContained>
<SelfContained Condition="'$(SelfContained)' == ''">false</SelfContained>
<UseAppHost Condition="'$(UseAppHost)' == '' and
('$(SelfContained)' == 'true' or
('$(RuntimeIdentifier)' != '' and '$(_TargetFrameworkVersionWithoutV)' >= '2.1') or
'$(_TargetFrameworkVersionWithoutV)' >= '3.0')">true</UseAppHost>
<UseAppHost Condition="'$(UseAppHost)' == ''">false</UseAppHost>
</PropertyGroup>
<!-- Only use the default apphost if building without a RID and without a deps file path (used by GenerateDeps.proj for CLI tools). -->
<PropertyGroup Condition="'$(DefaultAppHostRuntimeIdentifier)' == '' and
'$(RuntimeIdentifier)' == '' and
(('$(UseAppHost)' == 'true' and '$(ProjectDepsFilePath)' == '') or
('$(EnableComHosting)' == 'true' and '$(_IsExecutable)' != 'true') or
'$(UseIJWHost)' == 'true')">
<DefaultAppHostRuntimeIdentifier>$(NETCoreSdkRuntimeIdentifier)</DefaultAppHostRuntimeIdentifier>
<DefaultAppHostRuntimeIdentifier Condition="$(DefaultAppHostRuntimeIdentifier.StartsWith('win')) and '$(PlatformTarget)' == 'x64'">win-x64</DefaultAppHostRuntimeIdentifier>
<DefaultAppHostRuntimeIdentifier Condition="$(DefaultAppHostRuntimeIdentifier.StartsWith('win')) and '$(PlatformTarget)' == 'x86'">win-x86</DefaultAppHostRuntimeIdentifier>
<DefaultAppHostRuntimeIdentifier Condition="$(DefaultAppHostRuntimeIdentifier.StartsWith('win')) and '$(PlatformTarget)' == 'ARM'">win-arm</DefaultAppHostRuntimeIdentifier>
<DefaultAppHostRuntimeIdentifier Condition="$(DefaultAppHostRuntimeIdentifier.StartsWith('win')) and '$(PlatformTarget)' == 'ARM64'">win-arm64</DefaultAppHostRuntimeIdentifier>
</PropertyGroup>
<Target Name="_CheckForUnsupportedAppHostUsage"
BeforeTargets="_CheckForInvalidConfigurationAndPlatform"
Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and '$(HasRuntimeOutput)' == 'true'">
<NETSdkError Condition="'$(SelfContained)' == 'true' and '$(RuntimeIdentifier)' == ''"
ResourceName="CannotHaveSelfContainedWithoutRuntimeIdentifier" />
<NETSdkError Condition="'$(SelfContained)' == 'true' and '$(UseAppHost)' != 'true'"
ResourceName="CannotUseSelfContainedWithoutAppHost" />
<NETSdkError Condition="'$(PublishSingleFile)' == 'true' and '$(RuntimeIdentifier)' == ''"
ResourceName="CannotHaveSingleFileWithoutRuntimeIdentifier" />
<NETSdkError Condition="'$(PublishSingleFile)' == 'true' and '$(UseAppHost)' != 'true'"
ResourceName="CannotHaveSingleFileWithoutAppHost" />
<NETSdkError Condition="'$(SelfContained)' != 'true' and '$(UseAppHost)' == 'true' and '$(_TargetFrameworkVersionWithoutV)' < '2.1'"
ResourceName="FrameworkDependentAppHostRequiresVersion21" />
</Target>
<Target Name="_CheckForMismatchingPlatform"
BeforeTargets="_CheckForInvalidConfigurationAndPlatform"
Condition="'$(RuntimeIdentifier)' != '' and '$(PlatformTarget)' != ''">
<NETSdkError Condition="'$(PlatformTarget)' != 'AnyCPU' and !$(RuntimeIdentifier.ToUpperInvariant().Contains($(PlatformTarget.ToUpperInvariant())))"
ResourceName="CannotHaveRuntimeIdentifierPlatformMismatchPlatformTarget"
FormatArguments="$(RuntimeIdentifier);$(PlatformTarget)" />
</Target>
<Target Name="_CheckForLanguageAndFeatureCombinationSupport"
BeforeTargets="_CheckForInvalidConfigurationAndPlatform;ProcessFrameworkReferences">
<NETSdkError Condition="'$(Language)' == 'C++' and $(OutputType) != 'library' and '$(TargetFrameworkIdentifier)' == '.NETCoreApp'"
ResourceName="NoSupportCppNonDynamicLibraryDotnetCore" />
<NETSdkError Condition="'$(Language)' == 'C++' and $(EnableComHosting) == 'true'"
ResourceName="NoSupportCppEnableComHosting" />
</Target>
<Target Name="_CheckForNETCoreSdkIsPreview"
BeforeTargets="_CheckForInvalidConfigurationAndPlatform"
Condition=" '$(_NETCoreSdkIsPreview)' == 'true' AND '$(SuppressNETCoreSdkPreviewMessage)' != 'true' ">
<ShowPreviewMessage />
</Target>
<!-- Projects which don't use Microsoft.NET.Sdk will typically define the OutputPath directly (usually in a
Configuration-specific PropertyGroup), so in that case we won't append to it by default. -->
<PropertyGroup Condition="'$(UsingNETSdkDefaults)' == 'true'">
<!-- Projects can opt out of having the RID appended to the output path by setting this to false. -->
<AppendRuntimeIdentifierToOutputPath Condition="'$(AppendRuntimeIdentifierToOutputPath)' == ''">true</AppendRuntimeIdentifierToOutputPath>
</PropertyGroup>
<!--
Append $(RuntimeIdentifier) directory to output and intermediate paths to prevent bin clashes between
targets.
But do not append the implicit default runtime identifier for .NET Framework apps as that would
append a RID the user never mentioned in the path and do so even in the AnyCPU case.
-->
<PropertyGroup Condition="'$(AppendRuntimeIdentifierToOutputPath)' == 'true' and '$(RuntimeIdentifier)' != '' and '$(_UsingDefaultRuntimeIdentifier)' != 'true'">
<IntermediateOutputPath>$(IntermediateOutputPath)$(RuntimeIdentifier)\</IntermediateOutputPath>
<OutputPath>$(OutputPath)$(RuntimeIdentifier)\</OutputPath>
</PropertyGroup>
<UsingTask TaskName="Microsoft.NET.Build.Tasks.GetDefaultPlatformTargetForNetFramework"
AssemblyFile="$(MicrosoftNETBuildTasksAssembly)" />
<!--
Switch our default .NETFramework CPU architecture choice back to AnyCPU before
compiling the exe if no copy-local native dependencies were resolved from NuGet
-->
<Target Name="AdjustDefaultPlatformTargetForNetFrameworkExeWithNoNativeCopyLocalItems"
AfterTargets="ResolvePackageAssets"
BeforeTargets="CoreCompile"
Condition="'$(_UsingDefaultPlatformTarget)' == 'true' and
'$(_UsingDefaultRuntimeIdentifier)' == 'true'">
<GetDefaultPlatformTargetForNetFramework PackageDependencies="@(PackageDependencies)"
NativeCopyLocalItems="@(NativeCopyLocalItems)">
<Output TaskParameter="DefaultPlatformTarget" PropertyName="PlatformTarget" />
</GetDefaultPlatformTargetForNetFramework>
</Target>
</Project>
|