2 ***********************************************************************************************
3 Microsoft.NET.Sdk.Common.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">
14 <!-- This file is imported by both cross-targeting and inner builds. Set properties that need to be available to both here. -->
17 <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
18 <MicrosoftNETBuildTasksDirectoryRoot>$(MSBuildThisFileDirectory)..\tools\</MicrosoftNETBuildTasksDirectoryRoot>
19 <MicrosoftNETBuildTasksTFM Condition=" '$(MSBuildRuntimeType)' == 'Core'">netcoreapp1.0</MicrosoftNETBuildTasksTFM>
20 <MicrosoftNETBuildTasksTFM Condition=" '$(MicrosoftNETBuildTasksTFM)' == ''">net46</MicrosoftNETBuildTasksTFM>
21 <MicrosoftNETBuildTasksDirectory>$(MicrosoftNETBuildTasksDirectoryRoot)$(MicrosoftNETBuildTasksTFM)/</MicrosoftNETBuildTasksDirectory>
22 <MicrosoftNETBuildTasksAssembly>$(MicrosoftNETBuildTasksDirectory)Microsoft.NET.Build.Tasks.dll</MicrosoftNETBuildTasksAssembly>
25 Hardcoded list of known implicit packges that are added to project from default SDK targets implicitly.
26 Should be re-visited when multiple TFM support is added to Dependencies logic.
28 <DefaultImplicitPackages>Microsoft.NETCore.App;NETStandard.Library</DefaultImplicitPackages>
32 Some versions of Microsoft.NET.Test.Sdk.targets change the OutputType after we've set _IsExecutable and
33 HasRuntimeOutput default in Microsfot.NET.Sdk.BeforeCommon.targets. Refresh these value here for backwards
34 compatibilty with that.
37 <_IsExecutable Condition="'$(OutputType)' == 'Exe' or '$(OutputType)'=='WinExe'">true</_IsExecutable>
38 <HasRuntimeOutput Condition="'$(_UsingDefaultForHasRuntimeOutput)' == 'true'">$(_IsExecutable)</HasRuntimeOutput>
41 <PropertyGroup Condition="'$(DotnetCliToolTargetFramework)' == '' And '$(BundledNETCoreAppTargetFrameworkVersion)' != ''">
42 <!-- Set the TFM used to restore .NET CLI tools to match the version of .NET Core bundled in the CLI -->
43 <DotnetCliToolTargetFramework>netcoreapp$(BundledNETCoreAppTargetFrameworkVersion)</DotnetCliToolTargetFramework>
46 <UsingTask TaskName="GetNearestTargetFramework" AssemblyFile="$(MicrosoftNETBuildTasksAssembly)" />
47 <UsingTask TaskName="NETSdkError" AssemblyFile="$(MicrosoftNETBuildTasksAssembly)" />
50 ============================================================
51 GetTargetFrameworkProperties
53 Invoked by common targets to return the set of properties
54 (in the form "key1=value1;...keyN=valueN") needed to build
55 against the target framework that best matches the referring
56 project's target framework.
58 The referring project's $(TargetFrameworkMoniker) is passed
59 in as $(ReferringTargetFramework).
61 This is in the common targets so that it will apply to both
62 cross-targeted and single-targeted projects. It is run
63 for single-targeted projects so that an error will be
64 generated if the referenced project is not compatible
65 with the referencing project's target framework.
66 ============================================================
68 <Target Name="GetTargetFrameworkProperties" Returns="TargetFramework=$(NearestTargetFramework);ProjectHasSingleTargetFramework=$(_HasSingleTargetFramework);ProjectIsRidAgnostic=$(_IsRidAgnostic)">
71 <!-- indicate to caller that project is RID agnostic so that a global property RuntimeIdentifier value can be removed -->
72 <_IsRidAgnostic>false</_IsRidAgnostic>
73 <_IsRidAgnostic Condition=" '$(RuntimeIdentifier)' == '' and '$(RuntimeIdentifiers)' == '' ">true</_IsRidAgnostic>
75 <!-- If a ReferringTargetFramework was not specified, and we only have one TargetFramework, then don't try to check compatibility -->
76 <_SkipNearestTargetFrameworkResolution Condition="'$(TargetFramework)' != '' and '$(ReferringTargetFramework)' == ''">true</_SkipNearestTargetFrameworkResolution>
77 <NearestTargetFramework Condition="'$(_SkipNearestTargetFrameworkResolution)' == 'true'">$(TargetFramework)</NearestTargetFramework>
79 <!-- A project can only have more than one output if the current global properties are such that the current build is a cross-targeting one. -->
80 <_HasSingleTargetFramework Condition="'$(IsCrossTargetingBuild)' != 'true'">true</_HasSingleTargetFramework>
81 <_HasSingleTargetFramework Condition="'$(_HasSingleTargetFramework)' == ''">false</_HasSingleTargetFramework>
83 <_PossibleTargetFrameworks Condition="'$(TargetFramework)' != ''">$(TargetFramework)</_PossibleTargetFrameworks>
84 <_PossibleTargetFrameworks Condition="'$(TargetFramework)' == ''">$(TargetFrameworks)</_PossibleTargetFrameworks>
87 <GetNearestTargetFramework ReferringTargetFramework="$(ReferringTargetFramework)"
88 PossibleTargetFrameworks="$(_PossibleTargetFrameworks)"
89 ProjectFilePath="$(MSBuildProjectFullPath)"
90 Condition="'$(_SkipNearestTargetFrameworkResolution)' != 'true'">
91 <Output PropertyName="NearestTargetFramework" TaskParameter="NearestTargetFramework" />
92 </GetNearestTargetFramework>