LEFT | RIGHT |
(no file at all) | |
| 1 <!-- |
| 2 ********************************************************************************
*************** |
| 3 Microsoft.Bcl.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) Microsoft Corporation. All rights reserved. |
| 10 ********************************************************************************
*************** |
| 11 --> |
| 12 <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
| 13 <PropertyGroup> |
| 14 <BclBuildImported>true</BclBuildImported> |
| 15 </PropertyGroup> |
| 16 ·· |
| 17 <PropertyGroup Condition="'$(TargetFrameworkIdentifier)' != 'Silverlight' and
'$(OutputType)' != 'AppContainerExe'"> |
| 18 <!--· |
| 19 Workaround MSBuild issue that prevents System.Runtime 2.5 and System.Threa
ding.Tasks 2.5 from |
| 20 satisfying indirect dependencies on System.Runtime 1.5 and System.Threadin
g.Tasks 1.5 respectively.·· |
| 21 --> |
| 22 <AutoUnifyAssemblyReferences>false</AutoUnifyAssemblyReferences> |
| 23 |
| 24 <!-- MSBuild by default doesn't pass the Web.Config ResolveAssemblyReference
, in which case, set it so that it sees binding redirects --> |
| 25 <AppConfig Condition="'$(AppConfig)' == '' And '$(WebProjectOutputDir)' != '
' And Exists('$(ProjectConfigFileName)')">$(ProjectConfigFileName)</AppConfig> |
| 26 </PropertyGroup> |
| 27 |
| 28 <!-- Workaround issue that incorrectly unifies references not in the current p
rofile to the version in the superset of all profiles. --> |
| 29 <Target Name="_BclBuildSetFullFrameworkFolderToProfile" AfterTargets="GetRefer
enceAssemblyPaths" Condition="'$(TargetFrameworkIdentifier)' == '.NETPortable'"> |
| 30 <PropertyGroup> |
| 31 <_FullFrameworkReferenceAssemblyPaths>$(TargetFrameworkDirectory)</_FullFr
ameworkReferenceAssemblyPaths> |
| 32 </PropertyGroup> |
| 33 </Target> |
| 34 |
| 35 <!-- |
| 36 ****************************************************************************
*************************************** |
| 37 ****************************************************************************
*************************************** |
| 38
EnsureBindingRedirects Section |
| 39 ****************************************************************************
*************************************** |
| 40 ****************************************************************************
*************************************** |
| 41 --> |
| 42 <PropertyGroup> |
| 43 <__IntermediateAppConfig>$(IntermediateOutputPath)$(MSBuildProjectFile).App.
config</__IntermediateAppConfig> |
| 44 |
| 45 <SkipEnsureBindingRedirects Condition="'$(TargetFrameworkIdentifier)' == 'Si
lverlight' or '$(OutputType)' == 'AppContainerExe'">true</SkipEnsureBindingRedir
ects> |
| 46 </PropertyGroup> |
| 47 |
| 48 <UsingTask TaskName="EnsureBindingRedirects" AssemblyFile="$(MSBuildThisFileDi
rectory)Microsoft.Bcl.Build.Tasks.dll" /> |
| 49 |
| 50 <!--· |
| 51 ============================================================================
======================================= |
| 52
BclBuildDetermineReferencesToRedirect |
| 53 ······························ |
| 54 Determine which references are opted in for binding redirects |
| 55 ============================================================================
======================================= |
| 56 --> |
| 57 <Target Name="BclBuildDetermineReferencesToRedirect" BeforeTargets="BclBuildEn
sureBindingRedirects" Condition="'$(SkipEnsureBindingRedirects)' != 'true'"> |
| 58 <!-- Convention is a file next to the reference with name "ensureRedirect.xm
l" --> |
| 59 <ItemGroup> |
| 60 <_EnsureBindingRedirectReference Include="@(Reference)" |
| 61 Condition="'%(Reference.HintPath)' != ''
and Exists('$([System.IO.Path]::GetDirectoryName("%(Reference.HintPath)&quo
t;))\\ensureRedirect.xml')" /> |
| 62 </ItemGroup> |
| 63 </Target> |
| 64 |
| 65 <!--· |
| 66 ============================================================================
======================================= |
| 67
BclBuildEnsureBindingRedirects |
| 68 ······························ |
| 69 Generate a new app.config with merged binding redirects if we have binding r
edirects to ensure and it's out of date |
| 70 ============================================================================
======================================= |
| 71 --> |
| 72 <Target Name="BclBuildEnsureBindingRedirects" |
| 73 DependsOnTargets="BclBuildDetermineReferencesToRedirect" |
| 74 BeforeTargets="ResolveAssemblyReferences" |
| 75 Condition="'@(_EnsureBindingRedirectReference)' != '' and '$(SkipEnsur
eBindingRedirects)' != 'true'" |
| 76 Inputs="$(MSBuildAllProjects);$(AppConfig);@(_EnsureBindingRedirectRef
erence->'%(HintPath)')" |
| 77 Outputs="$(__IntermediateAppConfig)"> |
| 78 |
| 79 <EnsureBindingRedirects References="@(_EnsureBindingRedirectReference->'%(Hi
ntPath)')" |
| 80 SourceAppConfigPath="$(AppConfig)" |
| 81 DestinationAppConfigPath="$(__IntermediateAppConfig)
"> |
| 82 <Output TaskParameter="DestinationAppConfigPath" ItemName="FileWrites"/> |
| 83 </EnsureBindingRedirects> |
| 84 </Target> |
| 85 |
| 86 <!--· |
| 87 ============================================================================
======================================= |
| 88
BclBuildUpdateAppConfigWithTargetPath |
| 89 ······························ |
| 90 Update project properties to point to the generated app.config |
| 91 ============================================================================
======================================= |
| 92 --> |
| 93 <Target Name="BclBuildUpdateAppConfigWithTargetPath" |
| 94 DependsOnTargets="BclBuildDetermineReferencesToRedirect;BclBuildEnsure
BindingRedirects" |
| 95 BeforeTargets="ResolveAssemblyReferences" |
| 96 Condition="'@(_EnsureBindingRedirectReference)' != '' and '$(SkipEnsur
eBindingRedirects)' != 'true'"> |
| 97 <PropertyGroup> |
| 98 <AppConfig>$(__IntermediateAppConfig)</AppConfig> |
| 99 </PropertyGroup> |
| 100 <ItemGroup> |
| 101 <AppConfigWithTargetPath Remove="@(AppConfigWithTargetPath)" /> |
| 102 <AppConfigWithTargetPath Include="$(AppConfig)"> |
| 103 <TargetPath>$(TargetFileName).config</TargetPath> |
| 104 </AppConfigWithTargetPath> |
| 105 </ItemGroup> |
| 106 </Target> |
| 107 |
| 108 |
| 109 <!-- |
| 110 ****************************************************************************
*************************************** |
| 111 ****************************************************************************
*************************************** |
| 112
ValidatePackageReferences Section |
| 113 ···· |
| 114 This group of targets enables validation of nuget package references when bu
ilding inside VisualStudio. |
| 115 ****************************************************************************
*************************************** |
| 116 ****************************************************************************
*************************************** |
| 117 --> |
| 118 |
| 119 <!--· |
| 120 ============================================================================
======================================= |
| 121
BclBuildAddProjectReferenceProperties |
| 122 ······························ |
| 123 Adds properties to be set when resolving project references. The properties
ensure that the references get built |
| 124 in the context of the referencer (by changing the set of properties used to
build the project) and pass down the |
| 125 context needed to validate the referencing project. |
| 126 ============================================================================
======================================= |
| 127 --> |
| 128 <Target Name="BclBuildAddProjectReferenceProperties" |
| 129 BeforeTargets="AssignProjectConfiguration" |
| 130 Condition="'$(BuildingInsideVisualStudio)' == 'true'"> |
| 131 <PropertyGroup> |
| 132 <_BclBuildProjectReferenceProperties>BclBuildReferencingProject=$(MSBuildP
rojectFullPath);BclBuildReferencingProjectConfig=$(MSBuildProjectDirectory)\pack
ages.config</_BclBuildProjectReferenceProperties> |
| 133 <_BclBuildProjectReferenceProperties Condition="'$(SkipValidatePackageRefe
rences)' != ''">$(_BclBuildProjectReferenceProperties);SkipValidatePackageRefere
nces=$(SkipValidatePackageReferences)</_BclBuildProjectReferenceProperties> |
| 134 </PropertyGroup> |
| 135 |
| 136 <ItemGroup> |
| 137 <ProjectReference> |
| 138 <AdditionalProperties>$(_BclBuildProjectReferenceProperties);%(ProjectRe
ference.AdditionalProperties)</AdditionalProperties> |
| 139 </ProjectReference> |
| 140 </ItemGroup> |
| 141 </Target> |
| 142 |
| 143 <!--· |
| 144 ============================================================================
======================================= |
| 145
BclBuildSetRunningFullBuild |
| 146 ······························ |
| 147 Determines when a full build is running as opposed to a single target. |
| 148 ============================================================================
======================================= |
| 149 --> |
| 150 <Target Name="BclBuildSetRunningFullBuild" |
| 151 BeforeTargets="BuildOnlySettings"> |
| 152 <PropertyGroup> |
| 153 <BclBuildRunningFullBuild>true</BclBuildRunningFullBuild> |
| 154 </PropertyGroup> |
| 155 </Target> |
| 156 |
| 157 <!--· |
| 158 ============================================================================
======================================= |
| 159
GetTargetPath/BclBuildGetTargetPath |
| 160 ······························ |
| 161 MSBuild will only build a target once for a given set of properties. |
| 162 ···· |
| 163 We need that single build of GetTargetPath to run during project reference r
esolution, so that we can detect a· |
| 164 referencing project that doesn't have Bcl.Build. |
| 165 ···· |
| 166 To accomplish this we replace GetTargetPath with BclBuildGetTargetPath when
running a full build. |
| 167 ============================================================================
======================================= |
| 168 --> |
| 169 <Target |
| 170 Name="GetTargetPath" |
| 171 Condition="'$(BclBuildRunningFullBuild)' != 'true'" |
| 172 DependsOnTargets="$(GetTargetPathDependsOn)" |
| 173 Returns="$(TargetPath)"/> |
| 174 |
| 175 <Target |
| 176 Name="BclBuildGetTargetPath" |
| 177 Condition="'$(BclBuildRunningFullBuild)' == 'true'" |
| 178 AfterTargets="GetTargetPath" |
| 179 Returns="$(TargetPath)"> |
| 180 <PropertyGroup> |
| 181 <!-- Reset BclBuildRunningFullBuild, it will be set again when doing a ful
l build. --> |
| 182 <BclBuildRunningFullBuild>false</BclBuildRunningFullBuild> |
| 183 </PropertyGroup> |
| 184 </Target> |
| 185 |
| 186 <!--· |
| 187 ============================================================================
======================================= |
| 188
BclBuildValidateNugetPackageReferences |
| 189 ······························ |
| 190 This target validates that any Nuget packages installed in the current proje
ct are also installed in projects· |
| 191 referencing the current project. |
| 192 ···· |
| 193 This is necessary because Nuget packages contain more than just simple refer
ences. Installing the package ensures |
| 194 1. The right set of references for the target framework are added |
| 195 2. Config file transforms are applied |
| 196 3. Project installation scripts are run |
| 197 ······· |
| 198 For all packages listed as installed for the current project in packages con
fig, if the package ID matches one |
| 199 specified in @(ValidatePackages), ensure that the same package is installed
in the referencing project.· |
| 200 ···· |
| 201 This target can be disabled for a project reference by setting SkipValidateP
ackageReferences=true for the reference: |
| 202 <ProjectReference Include="..\pcl\pcl.csproj"> |
| 203 <Project>{664a9e98-fac7-4567-a046-0dde95fddb48}</Project> |
| 204 <Name>pcl</Name> |
| 205 <Properties>SkipValidatePackageReferences=true</Properties> |
| 206 </ProjectReference> |
| 207 ···· |
| 208 This target can be disabled for all references to a project by adding the fo
llowing: |
| 209 <PropertyGroup> |
| 210 <SkipValidatePackageReferences>true</SkipValidatePackageReferences> |
| 211 </PropertyGroup> |
| 212 ============================================================================
======================================= |
| 213 --> |
| 214 <UsingTask TaskName="ValidatePackageReferences" AssemblyFile="$(MSBuildThisFil
eDirectory)Microsoft.Bcl.Build.Tasks.dll" /> |
| 215 <Target Name="BclBuildValidateNugetPackageReferences" |
| 216 Condition="'$(BclBuildRunningFullBuild)' != 'true' AND '$(SkipValidate
PackageReferences)' != 'true' AND '$(BuildingInsideVisualStudio)' == 'true'" |
| 217 BeforeTargets="GetTargetPath"> |
| 218 <ItemGroup> |
| 219 <ValidatePackages Include="Microsoft.Bcl"/> |
| 220 <ValidatePackages Include="Microsoft.Bcl.Async"/> |
| 221 <ValidatePackages Include="Microsoft.Bcl.Compression"/> |
| 222 <ValidatePackages Include="Microsoft.Net.Http"/> |
| 223 </ItemGroup> |
| 224 |
| 225 <ValidatePackageReferences Packages="@(ValidatePackages)" |
| 226 ReferencingProject="$(BclBuildReferencingProject)
" |
| 227 ReferencingProjectPackagesConfig="$(BclBuildRefer
encingProjectConfig)" |
| 228 ReferencedProject="$(MSBuildProjectFullPath)" |
| 229 ReferencedProjectPackagesConfig="$(MSBuildProject
Directory)\packages.config" |
| 230 TreatWarningsAsErrors="$(TreatWarningsAsErrors)"
/> |
| 231 </Target> |
| 232 </Project> |
LEFT | RIGHT |