Skip to content

Commit fb28ce3

Browse files
authored
Simplify ref/ assembly generation (#24136)
* Simplify ref/ assembly generation - followup 1/2 for 5266918 - correct the Razor.Tools project - `%(Reference.Version)` metadata does not bleed through into `@(PackageReference)` items - much more work to do so than to add this special case - remove `$(Razor_NewtonsoftJsonPackageVersion)` - remove RTMVersions project and use RepoTasks instead - make it an error if RepoTasks is not restored before anything else builds - add items and properties for System.Security.AccessControl nits: - remove invalid (ignored) metadata in Directory.Build.props and AzureAppServices.SiteExtension project - improve / extend a couple of comments - move `@(Reference)` items together in Microsoft.AspNetCore.Razor.Tools
1 parent d7bcde5 commit fb28ce3

File tree

12 files changed

+41
-63
lines changed

12 files changed

+41
-63
lines changed

Directory.Build.props

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,7 @@
151151
Include="$(RepoRoot)src\Analyzers\Internal.AspNetCore.Analyzers\src\Internal.AspNetCore.Analyzers.csproj"
152152
ReferenceOutputAssembly="false"
153153
OutputItemType="Analyzer"
154-
PrivateAssets="All"
155-
Version="$(InternalAspNetCoreAnalyzersPackageVersion)"
156-
IsImplicitlyDefined="true" />
154+
PrivateAssets="All" />
157155
</ItemGroup>
158156

159157
<!-- Compilation options which apply to all languages. Language-specific options should be set in eng/targets/$(lang).Common.props -->

eng/Build.props

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@
4444
<!-- Project selection can be overridden on the command line by passing in -projects. -->
4545
<When Condition="'$(ProjectToBuild)' != ''">
4646
<ItemGroup>
47-
<!-- Include RTMVersions.csproj unless this invocation is building RepoTasks.csproj or won't compile C#. -->
48-
<ProjectToBuild Include="$(RepoRoot)eng\RTMVersions\RTMVersions.csproj"
49-
Exclude="@(ProjectToExclude)"
50-
Condition=" $(ProjectToBuild.EndsWith('.csproj')) AND !$(ProjectToBuild.EndsWith('RepoTasks.csproj')) " />
5147
<ProjectToBuild Include="$(ProjectToBuild)" Exclude="@(ProjectToExclude);$(RepoRoot)**\bin\**\*;$(RepoRoot)**\obj\**\*">
5248
<RestoreInParallel Condition="'%(Extension)' == '.npmproj'">false</RestoreInParallel>
5349
</ProjectToBuild>
@@ -125,11 +121,8 @@
125121
<!--
126122
Use caution to avoid deep recursion. If the globbing pattern picks up something which exceeds MAX_PATH,
127123
the entire pattern will silently fail to evaluate correctly.
128-
129-
Include RTMVersions.csproj when building any managed projects.
130124
-->
131125
<DotNetProjects Include="
132-
$(RepoRoot)eng\RTMVersions\RTMVersions.csproj;
133126
$(RepoRoot)src\Framework\App.Ref\src\Microsoft.AspNetCore.App.Ref.csproj;
134127
$(RepoRoot)src\Framework\App.Runtime\src\Microsoft.AspNetCore.App.Runtime.csproj;
135128
$(RepoRoot)src\Framework\App.Ref.Internal\src\Microsoft.AspNetCore.App.Ref.Internal.csproj;
@@ -178,7 +171,6 @@
178171
$(RepoRoot)**\obj\**\*;"
179172
Condition=" '$(BuildMainlyReferenceProviders)' != 'true' " />
180173
<DotNetProjects Include="
181-
$(RepoRoot)eng\RTMVersions\RTMVersions.csproj;
182174
$(RepoRoot)src\DefaultBuilder\**\src\*.csproj;
183175
$(RepoRoot)src\Features\JsonPatch\**\src\*.csproj;
184176
$(RepoRoot)src\DataProtection\**\src\*.csproj;

eng/Dependencies.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ and are generated based on the last package release.
7171
<LatestPackageReference Include="System.Reflection.Metadata" />
7272
<LatestPackageReference Include="System.Runtime.CompilerServices.Unsafe" />
7373
<LatestPackageReference Include="System.Runtime.InteropServices.RuntimeInformation" />
74+
<!-- System.Security.AccessControl should only be referenced in Dependencies.props and RTMVersions.csproj. -->
75+
<LatestPackageReference Include="System.Security.AccessControl" />
7476
<LatestPackageReference Include="System.Security.Cryptography.Cng" />
7577
<LatestPackageReference Include="System.Security.Cryptography.Pkcs" />
7678
<LatestPackageReference Include="System.Security.Cryptography.Xml" />

eng/RTMVersions/Directory.Build.props

Lines changed: 0 additions & 6 deletions
This file was deleted.

eng/RTMVersions/Directory.Build.targets

Lines changed: 0 additions & 1 deletion
This file was deleted.

eng/RTMVersions/RTMVersions.csproj

Lines changed: 0 additions & 28 deletions
This file was deleted.

eng/Version.Details.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,11 @@
233233
<Uri>https://github.com/dotnet/runtime</Uri>
234234
<Sha>f37dd6fc8595e130909dcb3085a56342d04aa20c</Sha>
235235
</Dependency>
236+
<!-- System.Security.AccessControl should only be referenced in Dependencies.props and RTMVersions.csproj. -->
237+
<Dependency Name="System.Security.AccessControl" Version="5.0.0-preview.8.20361.2">
238+
<Uri>https://github.com/dotnet/runtime</Uri>
239+
<Sha>f37dd6fc8595e130909dcb3085a56342d04aa20c</Sha>
240+
</Dependency>
236241
<Dependency Name="System.Security.Cryptography.Cng" Version="5.0.0-preview.8.20361.2">
237242
<Uri>https://github.com/dotnet/runtime</Uri>
238243
<Sha>f37dd6fc8595e130909dcb3085a56342d04aa20c</Sha>

eng/Versions.props

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@
116116
<SystemReflectionMetadataPackageVersion>5.0.0-preview.8.20361.2</SystemReflectionMetadataPackageVersion>
117117
<SystemResourcesExtensionsPackageVersion>5.0.0-preview.8.20361.2</SystemResourcesExtensionsPackageVersion>
118118
<SystemRuntimeCompilerServicesUnsafePackageVersion>5.0.0-preview.8.20361.2</SystemRuntimeCompilerServicesUnsafePackageVersion>
119+
<!-- System.Security.AccessControl should only be referenced in Dependencies.props and RTMVersions.csproj. -->
120+
<SystemSecurityAccessControlPackageVersion>5.0.0-preview.8.20361.2</SystemSecurityAccessControlPackageVersion>
119121
<SystemSecurityCryptographyCngPackageVersion>5.0.0-preview.8.20361.2</SystemSecurityCryptographyCngPackageVersion>
120122
<SystemSecurityCryptographyPkcsPackageVersion>5.0.0-preview.8.20361.2</SystemSecurityCryptographyPkcsPackageVersion>
121123
<SystemSecurityCryptographyXmlPackageVersion>5.0.0-preview.8.20361.2</SystemSecurityCryptographyXmlPackageVersion>
@@ -163,6 +165,14 @@
163165
Upshot is we need Major.Minor.0 runtime packages for compilation and the targeting pack and Major.Minor.Latest
164166
runtime packages for everything else. This is not an issue for assemblies available in Microsoft.NETCore.App.Ref or
165167
Microsoft.Extensions.Internal.Transport because it is next to impossible we would service those packages.
168+
169+
System.Security.AccessControl should only be referenced in Dependencies.props and RTMVersions.csproj. Because
170+
it's a transitive reference, we reship the ref/ assembly in Microsoft.AspNetCore.App.Ref. dotnet/runtime ships
171+
the implementation assemblies in Microsoft.NETCore.App.Runtime.* packages.
172+
173+
If testing this configuration prior to servicing, update the versions of dependencies too. E.g. change
174+
`$(SystemSecurityPrincipalWindowsV0PackageVersion)` if you change `$(SystemSecurityAccessControlV0PackageVersion)`
175+
because System.Security.AccessControl will otherwise be loadable. This should not be necessary in servicing.
166176
-->
167177
<PropertyGroup Condition=" '$(IsServicingBuild)' == 'true' ">
168178
<MicrosoftWin32RegistryV0PackageVersion>$(MicrosoftWin32RegistryPackageVersion.Split('.')[0]).$(MicrosoftWin32RegistryPackageVersion.Split('.')[1]).0</MicrosoftWin32RegistryV0PackageVersion>
@@ -252,9 +262,6 @@
252262
<MonoCecilPackageVersion>0.11.2</MonoCecilPackageVersion>
253263
<NewtonsoftJsonBsonPackageVersion>1.0.2</NewtonsoftJsonBsonPackageVersion>
254264
<NewtonsoftJsonPackageVersion>12.0.2</NewtonsoftJsonPackageVersion>
255-
<!-- Begin: STOP!!! Razor need to reference the version of JSON that our HOSTS support. -->
256-
<Razor_NewtonsoftJsonPackageVersion>9.0.1</Razor_NewtonsoftJsonPackageVersion>
257-
<!-- End: STOP!!! Razor need to reference the version of JSON that our HOSTS support. -->
258265
<NSwagApiDescriptionClientPackageVersion>13.0.4</NSwagApiDescriptionClientPackageVersion>
259266
<SeleniumSupportPackageVersion>3.12.1</SeleniumSupportPackageVersion>
260267
<SeleniumWebDriverMicrosoftDriverPackageVersion>17.17134.0</SeleniumWebDriverMicrosoftDriverPackageVersion>

eng/targets/ResolveReferences.targets

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
</Target>
128128

129129
<!--
130-
This target resolves remaining Referene items to Packages, if possible. If not, they are left as Reference items fo the SDK to resolve.
130+
This target resolves remaining Reference items to Packages, if possible. If not, they are left as Reference items fo the SDK to resolve.
131131
This executes on NuGet restore and during DesignTimeBuild. It should not run in the outer, cross-targeting build.
132132
-->
133133
<Target Name="ResolveCustomReferences"
@@ -205,21 +205,23 @@
205205
</Target>
206206

207207
<!--
208-
Muck with @(ResolvedCompileFileDefinitions) items between generation and use in order to compile against RTM lib/
208+
Change @(ResolvedCompileFileDefinitions) items between generation and use in order to compile against RTM lib/
209209
or ref/ assemblies. The approach works for all TFMs because it happens after a specific assembly is chosen for
210210
compilation; no need to restrict this to (say) the default TFM.
211211
212-
Condition checks for RTMVersions.csproj.nuget.g.props file only to ensure restore operation is complete.
213-
214212
This target could get confused if the layout changes for one of the dozen special-cased packages during servicing.
215213
E.g. ResolvePackageAssets picks a compatible assembly from the 5.0.1 package and _UseRTMReferenceAssemblies
216214
changes the path to one not present in the 5.0.0 package. Fortunately, this will break the build with complaints
217215
about the "invalid strong name".
218216
-->
219217
<Target Name="_UseRTMReferenceAssemblies"
220-
Condition=" '$(EnableCustomReferenceResolution)' == 'true' AND EXISTS('$(RepoRoot)eng\RTMVersions\obj\RTMVersions.csproj.nuget.g.props') "
218+
Condition=" '$(MSBuildProjectName)' != 'RepoTasks' "
219+
AfterTargets="ResolvePackageAssets"
221220
BeforeTargets="GenerateBuildDependencyFile;GeneratePublishDependencyFile;ILLink;ResolveLockFileReferences"
222221
DependsOnTargets="ResolvePackageAssets">
222+
<Error Condition=" !EXISTS('$(RepoRoot)artifacts\obj\RepoTasks\RepoTasks.csproj.nuget.g.props') "
223+
Text="The eng/tools/RepoTasks project must be restored before building other projects." />
224+
223225
<JoinItems Left="@(ResolvedCompileFileDefinitions)"
224226
Right="@(LatestPackageReference->HasMetadata('RTMVersion'))"
225227
LeftKey="Filename"

eng/tools/RepoTasks/RepoTasks.csproj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,15 @@
3636
<Reference Include="Microsoft.Deployment.WindowsInstaller.Package">
3737
<HintPath>$(WiXSdkPath)\Microsoft.Deployment.WindowsInstaller.Package.dll</HintPath>
3838
</Reference>
39+
40+
<!--
41+
Gather project references for compilation against RTM packages. %(RTMVersion) is set for about a dozen packages
42+
in all servicing builds. Cannot reference two versions of a package, mandating this separation from projects
43+
using the relevant packages.
44+
-->
45+
<PackageReference Include="@(LatestPackageReference->HasMetadata('RTMVersion'))"
46+
IncludeAssets="None"
47+
PrivateAssets="All"
48+
Version="%(RTMVersion)" />
3949
</ItemGroup>
4050
</Project>

src/Razor/Microsoft.AspNetCore.Razor.Tools/src/Microsoft.AspNetCore.Razor.Tools.csproj

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,10 @@
3636
<Compile Include="$(SharedSourceRoot)CommandLineUtils\**\*.cs" />
3737
</ItemGroup>
3838

39-
<ItemGroup>
40-
<Reference Include="Newtonsoft.Json" Version="$(Razor_NewtonsoftJsonPackageVersion)" />
41-
<Reference Include="Microsoft.Css.Parser" Version="$(MicrosoftCssParserPackageVersion)" />
42-
</ItemGroup>
43-
4439
<ItemGroup>
4540
<Reference Include="Microsoft.CodeAnalysis.Razor" />
41+
<Reference Include="Microsoft.Css.Parser" />
42+
<Reference Include="Newtonsoft.Json" />
4643
</ItemGroup>
4744

4845
<!-- This makes it so that the runtimeconfig.json is included as part of the build output of the project that references this project. -->

src/SiteExtensions/LoggingAggregate/src/Microsoft.AspNetCore.AzureAppServices.SiteExtension/Microsoft.AspNetCore.AzureAppServices.SiteExtension.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
</PropertyGroup>
2525

2626
<ItemGroup>
27-
<Reference Include="Microsoft.AspNetCore.AzureAppServices.SiteExtension.2.1" Version="$(MicrosoftAspNetCoreAzureAppServicesSiteExtension21PackageVersion)" PrivateAssets="All" />
28-
<Reference Include="Microsoft.AspNetCore.AzureAppServices.SiteExtension.2.2" Version="$(MicrosoftAspNetCoreAzureAppServicesSiteExtension22PackageVersion)" PrivateAssets="All" />
29-
<Reference Include="Microsoft.AspNetCore.AzureAppServices.SiteExtension.3.1.x64" Version="$(MicrosoftAspNetCoreAzureAppServicesSiteExtension31PackageVersion)" PrivateAssets="All" />
30-
<Reference Include="Microsoft.AspNetCore.AzureAppServices.SiteExtension.3.1.x86" Version="$(MicrosoftAspNetCoreAzureAppServicesSiteExtension31PackageVersion)" PrivateAssets="All" />
27+
<Reference Include="Microsoft.AspNetCore.AzureAppServices.SiteExtension.2.1" PrivateAssets="All" />
28+
<Reference Include="Microsoft.AspNetCore.AzureAppServices.SiteExtension.2.2" PrivateAssets="All" />
29+
<Reference Include="Microsoft.AspNetCore.AzureAppServices.SiteExtension.3.1.x64" PrivateAssets="All" />
30+
<Reference Include="Microsoft.AspNetCore.AzureAppServices.SiteExtension.3.1.x86" PrivateAssets="All" />
3131
<!-- When updating this add the previous SiteExtension(s) to the list above -->
3232
<PackageReference Include="Microsoft.AspNetCore.AzureAppServices.SiteExtension.5.0.x86" Version="$(PackageVersion)" PrivateAssets="All" />
3333
<PackageReference Include="Microsoft.AspNetCore.AzureAppServices.SiteExtension.5.0.x64" Version="$(PackageVersion)" PrivateAssets="All" />

0 commit comments

Comments
 (0)