2 ***********************************************************************************************
3 Microsoft.NET.Sdk.BeforeCommon.targets
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.
9 Copyright (c) .NET Foundation. All rights reserved.
10 ***********************************************************************************************
12 <Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
15 <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
16 <_IsExecutable Condition="'$(OutputType)' == 'Exe' or '$(OutputType)'=='WinExe'">true</_IsExecutable>
19 <PropertyGroup Condition="'$(HasRuntimeOutput)' == ''">
20 <HasRuntimeOutput>$(_IsExecutable)</HasRuntimeOutput>
21 <_UsingDefaultForHasRuntimeOutput>true</_UsingDefaultForHasRuntimeOutput>
24 <Import Project="$(MSBuildThisFileDirectory)Microsoft.NET.DefaultAssemblyInfo.targets" />
26 <!-- Set default intermediate and output paths -->
27 <Import Project="$(MSBuildThisFileDirectory)Microsoft.NET.DefaultOutputPaths.targets" />
30 Expand TargetFramework to TargetFrameworkIdentifier and TargetFrameworkVersion,
31 and adjust intermediate and output paths to include it.
33 <Import Project="$(MSBuildThisFileDirectory)Microsoft.NET.TargetFrameworkInference.targets" />
36 Use RuntimeIdentifier to determine PlatformTarget.
37 Also, enforce that RuntimeIdentifier is always specified for .NETFramework executables.
39 <Import Project="$(MSBuildThisFileDirectory)Microsoft.NET.RuntimeIdentifierInference.targets" />
41 <PropertyGroup Condition="'$(_IsNETCoreOrNETStandard)' == ''">
42 <_IsNETCoreOrNETStandard Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">true</_IsNETCoreOrNETStandard>
43 <_IsNETCoreOrNETStandard Condition="'$(TargetFrameworkIdentifier)' == '.NETStandard'">true</_IsNETCoreOrNETStandard>
46 <!-- Unification / automatic binding redirect logic -->
48 <DesignTimeAutoUnify Condition="'$(DesignTimeAutoUnify)' == ''">true</DesignTimeAutoUnify>
49 <AutoUnifyAssemblyReferences Condition="'$(AutoUnifyAssemblyReferences)' == '' and $(OutputType) == 'Library'">true</AutoUnifyAssemblyReferences>
50 <AutoUnifyAssemblyReferences Condition="'$(AutoUnifyAssemblyReferences)' == '' and '$(_IsNETCoreOrNETStandard)' == 'true'">true</AutoUnifyAssemblyReferences>
52 <PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework' and '$(HasRuntimeOutput)' == 'true'">
53 <AutoGenerateBindingRedirects Condition="'$(AutoGenerateBindingRedirects)' == ''">true</AutoGenerateBindingRedirects>
56 <!-- Default settings for .NET Core and .NET Standard build logic -->
57 <PropertyGroup Condition="'$(_IsNETCoreOrNETStandard)' == 'true'">
58 <GenerateDependencyFile Condition=" '$(GenerateDependencyFile)' == '' ">true</GenerateDependencyFile>
60 <!-- Force .dll extension for .NETCoreApp and .NETStandard projects even if output type is exe. -->
61 <TargetExt Condition="'$(TargetExt)' == ''">.dll</TargetExt>
63 <!-- dependencies coming from the package manager lock file should not be copied locally for .NET Core and .NETStandard projects -->
64 <CopyLocalLockFileAssemblies Condition="'$(CopyLocalLockFileAssemblies)' == ''">false</CopyLocalLockFileAssemblies>
66 <!-- Disable the use of FrameworkPathOverride in Microsoft.Common.CurrentVersion.targets which can slow down evaluation. FrameworkPathOverride
67 is not needed for NETStandard or NETCore since references come from NuGet packages-->
68 <EnableFrameworkPathOverride Condition="'$(EnableFrameworkPathOverride)' == ''">false</EnableFrameworkPathOverride>
71 <!-- Regardless of platform, enable dependency file generation if PreserveCompilatioContext is set. -->
73 <GenerateDependencyFile Condition="'$(GenerateDependencyFile)' == ''">$(PreserveCompilationContext)</GenerateDependencyFile>
76 <!-- Set PublishDir here, before Microsoft.Common.targets, to avoid a competing default there. -->
78 <PublishDirName Condition="'$(PublishDirName)' == ''">publish</PublishDirName>
79 <!-- ensure the PublishDir is RID specific-->
80 <PublishDir Condition="'$(PublishDir)' == '' and
81 '$(AppendRuntimeIdentifierToOutputPath)' != 'true' and
82 '$(RuntimeIdentifier)' != '' and
83 '$(_UsingDefaultRuntimeIdentifier)' != 'true'">$(OutputPath)$(RuntimeIdentifier)\$(PublishDirName)\</PublishDir>
84 <PublishDir Condition="'$(PublishDir)' == ''">$(OutputPath)$(PublishDirName)\</PublishDir>
87 <!-- For .NET Framework, reference core assemblies -->
90 <_TargetFrameworkVersionWithoutV>$(TargetFrameworkVersion)</_TargetFrameworkVersionWithoutV>
91 <_TargetFrameworkVersionWithoutV Condition="$(TargetFrameworkVersion.StartsWith('v'))">$(TargetFrameworkVersion.Substring(1))</_TargetFrameworkVersionWithoutV>
95 Sets RestoreAdditionalProjectSources or RestoreAdditionalProjectFallbackFolders to the SDK Offline Cache based
96 on the TargetFramework.
98 <Import Project="$(MSBuildThisFileDirectory)Microsoft.NET.NuGetOfflineCache.targets" />
100 <ItemGroup Condition=" '$(DisableImplicitFrameworkReferences)' != 'true' and '$(TargetFrameworkIdentifier)' == '.NETFramework'">
102 <_SDKImplicitReference Include="System"/>
103 <_SDKImplicitReference Include="System.Data"/>
104 <_SDKImplicitReference Include="System.Drawing"/>
105 <_SDKImplicitReference Include="System.Xml"/>
107 <!-- When doing greater than/less than comparisons between strings, MSBuild will try to parse the strings as Version objects and compare them as
108 such if the parse succeeds. -->
110 <!-- Framework assemblies introduced in .NET 3.5 -->
111 <_SDKImplicitReference Include="System.Core" Condition=" '$(_TargetFrameworkVersionWithoutV)' >= '3.5' "/>
112 <_SDKImplicitReference Include="System.Runtime.Serialization" Condition=" '$(_TargetFrameworkVersionWithoutV)' >= '3.5' "/>
113 <_SDKImplicitReference Include="System.Xml.Linq" Condition=" '$(_TargetFrameworkVersionWithoutV)' >= '3.5' "/>
115 <!-- Framework assemblies introduced in .NET 4.0 -->
116 <_SDKImplicitReference Include="System.Numerics" Condition=" '$(_TargetFrameworkVersionWithoutV)' >= '4.0' "/>
118 <!-- Framework assemblies introduced in .NET 4.5 -->
119 <_SDKImplicitReference Include="System.IO.Compression.FileSystem" Condition=" '$(_TargetFrameworkVersionWithoutV)' >= '4.5' "/>
121 <!-- Don't automatically reference System.IO.Compression or System.Net.Http to help avoid hitting https://github.com/Microsoft/msbuild/issues/1329. -->
122 <!--<Reference Include="System.IO.Compression" Condition=" '$(_TargetFrameworkVersionWithoutV)' >= '4.5' "/>
123 <_SDKImplicitReference Include="System.Net.Http" Condition=" '$(_TargetFrameworkVersionWithoutV)' >= '4.5' "/>-->
125 <!-- Set Pack=false on implicit references so they don't get added to NuGet packages as framework assemblies -->
126 <_SDKImplicitReference Update="@(_SDKImplicitReference)"
129 <!-- Don't duplicate any references that are explicit in the project file. This means that if you do want to include a framework assembly in your
130 NuGet package, you can just add the Reference to your project file. -->
131 <_SDKImplicitReference Remove="@(Reference)" />
133 <!-- Add the implicit references to @(Reference) -->
134 <Reference Include="@(_SDKImplicitReference)" />
138 <!-- Prevent System.Core reference from being added separately (see Microsoft.NETFramework.CurrentVersion.props) -->
139 <AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>
142 <PropertyGroup Condition="'$(DisableImplicitAssetTargetFallback)' != 'true' and '$(_IsNETCoreOrNETStandard)' == 'true' and '$(_TargetFrameworkVersionWithoutV)' >= '2.0'">
143 <AssetTargetFallback>$(AssetTargetFallback);net461</AssetTargetFallback>
146 <!-- Add conditional compilation symbols for the target framework (for example NET461, NETSTANDARD2_0, NETCOREAPP1_0) -->
147 <PropertyGroup Condition=" '$(DisableImplicitFrameworkDefines)' != 'true' and '$(TargetFrameworkIdentifier)' != '.NETPortable' and '$(TargetFrameworkIdentifier)' != ''">
148 <_FrameworkIdentifierForImplicitDefine>$(TargetFrameworkIdentifier.Replace('.', '').ToUpperInvariant())</_FrameworkIdentifierForImplicitDefine>
149 <_FrameworkIdentifierForImplicitDefine Condition=" '$(TargetFrameworkIdentifier)' == '.NETFramework'">NET</_FrameworkIdentifierForImplicitDefine>
151 <_FrameworkVersionForImplicitDefine Condition="$(TargetFrameworkVersion.StartsWith('v'))">$(TargetFrameworkVersion.SubString(1))</_FrameworkVersionForImplicitDefine>
152 <_FrameworkVersionForImplicitDefine Condition="!$(TargetFrameworkVersion.StartsWith('v'))">$(TargetFrameworkVersion)</_FrameworkVersionForImplicitDefine>
154 <_FrameworkVersionForImplicitDefine>$(_FrameworkVersionForImplicitDefine.Replace('.', '_'))</_FrameworkVersionForImplicitDefine>
156 <_FrameworkVersionForImplicitDefine Condition=" '$(TargetFrameworkIdentifier)' == '.NETFramework'">$(_FrameworkVersionForImplicitDefine.Replace('_', ''))</_FrameworkVersionForImplicitDefine>
158 <ImplicitFrameworkDefine>$(_FrameworkIdentifierForImplicitDefine)$(_FrameworkVersionForImplicitDefine)</ImplicitFrameworkDefine>
161 <!-- Handle XML documentation file settings -->
162 <PropertyGroup Condition="'$(GenerateDocumentationFile)' == ''">
163 <GenerateDocumentationFile Condition="'$(DocumentationFile)' == ''">false</GenerateDocumentationFile>
164 <GenerateDocumentationFile Condition="'$(DocumentationFile)' != ''">true</GenerateDocumentationFile>
167 <PropertyGroup Condition="'$(GenerateDocumentationFile)' == 'true' and '$(DocumentationFile)' == ''">
168 <DocumentationFile>$(IntermediateOutputPath)$(AssemblyName).xml</DocumentationFile>
171 <PropertyGroup Condition="'$(GenerateDocumentationFile)' != 'true'">
172 <DocumentationFile />
176 <PublishDocumentationFiles Condition="'$(PublishDocumentationFiles)' == ''">true</PublishDocumentationFiles>
177 <PublishDocumentationFile Condition="'$(PublishDocumentationFile)' == '' and '$(PublishDocumentationFiles)' == 'true'">true</PublishDocumentationFile>
178 <PublishReferencesDocumentationFiles Condition="'$(PublishReferencesDocumentationFiles)' == '' and '$(PublishDocumentationFiles)' == 'true'">true</PublishReferencesDocumentationFiles>
181 <!-- Add a project capability so that the project properties in the IDE can show the option to generate an XML documentation file without specifying the filename -->
183 <ProjectCapability Include="GenerateDocumentationFile" />