|
20 | 20 | <Project>
|
21 | 21 |
|
22 | 22 | <PropertyGroup>
|
23 |
| - <EnableCustomReferenceResolution Condition="'$(EnableCustomReferenceResolution)' == '' AND ('$(DotNetBuildFromSource)' != 'true' OR '$(ExcludeFromSourceBuild)' != 'true')">true</EnableCustomReferenceResolution> |
| 23 | + <EnableCustomReferenceResolution |
| 24 | + Condition="'$(EnableCustomReferenceResolution)' == '' AND ('$(DotNetBuildFromSource)' != 'true' OR '$(ExcludeFromSourceBuild)' != 'true')">true</EnableCustomReferenceResolution> |
24 | 25 |
|
25 | 26 | <ResolveReferencesDependsOn>
|
26 | 27 | ResolveCustomReferences;
|
|
35 | 36 | * when a project is a test or sample project
|
36 | 37 | * when a package is releasing a new patch (we like to update external dependencies in patches when possible)
|
37 | 38 | That is, use latest package references unless this is a servicing build, the project is normally packable, and
|
38 |
| - the package is not included in this release. |
| 39 | + the package is not included in this release. The "unless" cases are extremely unlikely because both |
| 40 | + $(IsPackableInNonServicingBuild) and $(IsPackageInThisPatch) are either undefined or true. |
39 | 41 | -->
|
40 | 42 | <UseLatestPackageReferences
|
41 |
| - Condition=" '$(UseLatestPackageReferences)' == '' AND '$(IsServicingBuild)' != 'true' ">true</UseLatestPackageReferences> |
| 43 | + Condition=" '$(UseLatestPackageReferences)' == '' AND '$(IsServicingBuild)' != 'true' ">true</UseLatestPackageReferences> |
42 | 44 | <UseLatestPackageReferences
|
43 | 45 | Condition=" '$(UseLatestPackageReferences)' == '' AND '$(IsPackableInNonServicingBuild)' != 'true' ">true</UseLatestPackageReferences>
|
44 | 46 | <UseLatestPackageReferences
|
|
99 | 101 | <_OriginalReferences Include="@(Reference)" />
|
100 | 102 |
|
101 | 103 | <!--
|
102 |
| - Turn Reference items into a ProjectReference when UseProjectReferences is true. |
103 |
| - Order matters. This comes before package resolution because projects should be used when possible instead of packages. |
| 104 | + Turn Reference items into a ProjectReference when UseProjectReferences is true. Order matters; this |
| 105 | + comes before package resolution because projects should be used when possible instead of packages. |
104 | 106 | -->
|
105 | 107 | <_ProjectReferenceByAssemblyName Condition="'$(UseProjectReferences)' == 'true'"
|
106 | 108 | Include="@(ProjectReferenceProvider)"
|
|
121 | 123 | </ItemGroup>
|
122 | 124 |
|
123 | 125 | <!--
|
124 |
| - This target helps ensure projects within the shared framework do not unintentionally add new references, |
125 |
| - and that assemblies outside the shared framework reference the framework as a whole instead of using |
126 |
| - individual assemblies. |
| 126 | + This target helps ensure projects within the shared framework do not unintentionally add new references, and that |
| 127 | + assemblies outside the shared framework reference the framework as a whole instead of using individual assemblies. |
| 128 | + In addition, enforce use of Reference items for projects reference providers. |
127 | 129 | -->
|
128 | 130 | <Target Name="_CheckForReferenceBoundaries" BeforeTargets="CollectPackageReferences;ResolveReferences">
|
129 |
| - <Error Condition="@(_InvalidReferenceToSharedFxOnlyAssembly->Count()) != 0" |
130 |
| - Text="Cannot reference "%(_InvalidReferenceToSharedFxOnlyAssembly.Identity)" directly because it is part of the shared framework and this project is not. Use <FrameworkReference Include="Microsoft.AspNetCore.App" /> instead." /> |
131 |
| - |
132 | 131 | <Error Condition="@(_InvalidReferenceToNonSharedFxAssembly->Count()) != 0"
|
133 |
| - Text="Cannot reference "%(_InvalidReferenceToNonSharedFxAssembly.Identity)". This dependency is not in the shared framework. See docs/SharedFramework.md for instructions on how to modify what is in the shared framework." /> |
| 132 | + Text="Cannot reference "%(Identity)". This dependency is not in the shared framework. See docs/SharedFramework.md for instructions on how to modify what is in the shared framework." /> |
134 | 133 | </Target>
|
135 | 134 |
|
136 | 135 | <Target Name="_WarnAboutRedundantRef" AfterTargets="ResolveFrameworkReferences;ProcessFrameworkReferences">
|
|
140 | 139 | </Target>
|
141 | 140 |
|
142 | 141 | <!--
|
143 |
| - This target resolves remaining Reference items to Packages, if possible. If not, they are left as Reference items fo the SDK to resolve. |
144 |
| - This executes on NuGet restore and during DesignTimeBuild. It should not run in the outer, cross-targeting build. |
| 142 | + This target resolves remaining Reference items to Packages, if possible. If not, they are left as Reference |
| 143 | + items for the SDK to resolve. This executes on NuGet restore and during DesignTimeBuild. It should not run in |
| 144 | + outer, cross-targeting build. |
145 | 145 | -->
|
146 | 146 | <Target Name="ResolveCustomReferences"
|
147 | 147 | BeforeTargets="CheckForImplicitPackageReferenceOverrides;CollectPackageReferences;ResolvePackageAssets"
|
148 | 148 | Condition=" '$(TargetFramework)' != '' AND '$(EnableCustomReferenceResolution)' == 'true' ">
|
149 | 149 | <ItemGroup>
|
150 |
| - <!-- Ensure only content asset are consumed from .Sources packages --> |
| 150 | + <!-- Ensure only content assets are consumed from .Sources packages. --> |
151 | 151 | <Reference>
|
152 | 152 | <IncludeAssets Condition="'%(IsSharedSource)' == 'true'">ContentFiles;Build</IncludeAssets>
|
153 | 153 | <PrivateAssets Condition="'%(IsSharedSource)' == 'true'">All</PrivateAssets>
|
|
176 | 176 | <_LatestPackageReferenceWithVersion Remove="@(_LatestPackageReferenceWithVersion)"
|
177 | 177 | Condition="'%(Id)' != '%(Identity)' " />
|
178 | 178 |
|
| 179 | + <PackageReference Include="@(_LatestPackageReferenceWithVersion)" IsImplicitlyDefined="true" /> |
179 | 180 | <!-- Remove reference items that have been resolved to a LatestPackageReference item. -->
|
180 | 181 | <Reference Remove="@(_LatestPackageReferenceWithVersion)" />
|
181 |
| - <PackageReference Include="@(_LatestPackageReferenceWithVersion)" IsImplicitlyDefined="true" /> |
182 | 182 |
|
183 | 183 | <!-- Resolve references from BaselinePackageReference for servicing builds in corner cases. May be unused. -->
|
184 | 184 | <_BaselinePackageReferenceWithVersion Include="@(Reference)"
|
|
189 | 189 | <_BaselinePackageReferenceWithVersion Remove="@(_BaselinePackageReferenceWithVersion)"
|
190 | 190 | Condition="'%(Id)' != '%(Identity)' " />
|
191 | 191 |
|
192 |
| - <!-- Remove reference items that have been resolved to a BaselinePackageReference item. --> |
193 | 192 | <PackageReference Include="@(_BaselinePackageReferenceWithVersion)" IsImplicitlyDefined="true" />
|
| 193 | + <!-- Remove reference items that have been resolved to a BaselinePackageReference item. --> |
194 | 194 | <Reference Remove="@(_BaselinePackageReferenceWithVersion)" />
|
195 | 195 |
|
196 | 196 | <!-- For PrivateAssets=All references, like .Sources packages, fallback to LatestPackageReferences. -->
|
|
201 | 201 | <_PrivatePackageReferenceWithVersion Remove="@(_PrivatePackageReferenceWithVersion)"
|
202 | 202 | Condition="'%(Id)' != '%(Identity)' " />
|
203 | 203 |
|
204 |
| - <!-- Remove reference items that have been resolved to an item with PrivateAssets="All". --> |
205 | 204 | <PackageReference Include="@(_PrivatePackageReferenceWithVersion)" IsImplicitlyDefined="true" />
|
| 205 | + <!-- Remove reference items that have been resolved to an item with PrivateAssets="All". --> |
206 | 206 | <Reference Remove="@(_PrivatePackageReferenceWithVersion)" />
|
207 | 207 |
|
208 | 208 | <!-- Free up memory for unnecessary items -->
|
|
228 | 228 | <Error
|
229 | 229 | Condition="'$(IsReferenceAssemblyProject)' != 'true' AND '$(IsServicingBuild)' == 'true' AND @(UnusedBaselinePackageReference->Count()) != 0"
|
230 | 230 | Code="BUILD002"
|
231 |
| - Text="Package references changed since the last release. This could be a breaking change and is not allowed in a servicing update. References removed:%0A - @(UnusedBaselinePackageReference, '%0A -')" /> |
| 231 | + Text="Package references changed since the last release. This could be a breaking change and is not allowed in a servicing update. References removed:%0A - @(UnusedBaselinePackageReference, '%0A - ')" /> |
232 | 232 |
|
233 | 233 | <Error
|
234 | 234 | Condition="'$(TargetFrameworkIdentifier)' != '.NETFramework' AND '%(Reference.Identity)' != '' AND ! Exists('%(Reference.Identity)') AND '$(DisablePackageReferenceRestrictions)' != 'true'"
|
|
339 | 339 | Condition="'$(SkipRefDirectoryCheck)' != 'true' AND '$(IsImplementationProject)' == 'true' AND !$(HasReferenceAssembly) AND Exists($(ReferenceAssemblyDirectory))"
|
340 | 340 | Text="Project shouldn't have reference assembly but folder exists $(ReferenceAssemblyDirectory)" />
|
341 | 341 | <Error
|
342 |
| - Condition=" '$(IsAspNetCoreApp)' == 'true' AND '$(IsImplementationProject)' == 'true' AND !$(HasReferenceAssembly) " |
343 |
| - Text="All assemblies which have set IsAspNetCoreApp=true should produce a reference assembly." /> |
344 |
| - <Warning Condition=" '$(IsAspNetCoreApp)' == 'true' AND '$(IsImplementationProject)' != 'true' " |
| 342 | + Condition=" '$(IsAspNetCoreApp)' == 'true' AND '$(IsImplementationProject)' == 'true' AND |
| 343 | + !$(HasReferenceAssembly) AND '$(TargetFramework)' == '$(DefaultNetCoreTargetFramework)' " |
| 344 | + Text="All assemblies which have set IsAspNetCoreApp=true should produce a reference assembly for default TFM." /> |
| 345 | + <Error Condition=" '$(IsAspNetCoreApp)' == 'true' AND '$(IsImplementationProject)' != 'true' " |
345 | 346 | Text="Only implementation projects should set IsAspNetCoreApp=true." />
|
346 |
| - <Warning Condition=" '$(IsAspNetCoreApp)' != 'true' AND $(HasReferenceAssembly) " |
| 347 | + <Error Condition=" '$(IsAspNetCoreApp)' != 'true' AND $(HasReferenceAssembly) " |
347 | 348 | Text="Only projects in the shared framework i.e. IsAspNetCoreApp==true should produce a reference assembly." />
|
348 | 349 |
|
349 | 350 | <ItemGroup Condition=" '$(IsProjectReferenceProvider)' == 'true' ">
|
|
0 commit comments