Skip to content

Commit 0b3703e

Browse files
Copy local intellisense xmls for assemblies with source of truth. (dotnet#79134)
* Copy local intellisense xmls for assemblies with source of truth. * use UseIntellisenseDocumentationFile instead * Create intellisense.targets, which contains the Target that defines the set of files to copy, and the Target that copies each of those files into the artifacts/bin/docs folder. The paths of the files to copy are dynamically defined depending if the assembly IsPackable property is set or not, and if the UseIntellisenseDocumentationFile boolean is set or not. * Set UseIntellisenseDocumentationFile to true for the 3 assemblies that already have their source of truth in triple slash. * Delete docs.targets, move package download to Build.proj * Consume $(XmlDocDir) in Microsoft.NetCore.App.Ref.sfxproj * Change condition to import intellisense.targets: Use $(IsSourceProject) == true * Move XmlDocFileRoot to intellisense.targets, address suggestions for collecting xml file. * Expand condition of CopyDocumentationFileToXmlDocDir to also check if IsNetCoreAppSrc == true. * Change AfterTargets of CopyDocumentationFileToXmlDocDir from CoreCompile to CopyFilesToOutputDirectory * Move PackageDownload to intellisense.targets * Remove Choose+When. Readjust properties for Private.Intellisense files/folders. Fix conditions for doc file swap. * Rename csproj property to something more clear. * Default csproj property to true. * Missed adding the "not previously set" condition for UseIntellisensePackageDocXmlFile in intellisense.targets. * Remove incorrect condition in CopyDocumentationFileToXmlDocDir. * Missed property reuse in Condition in sfxproj * Only evaluate second IntellisensePackageXmlFile if the first one did not acquire any value. * Move intellisense.targets import from root to libraries, right after the IsNetCoreAppSrc property is declared so we can use it. * Enable CS1591, skip arcade warning * Move SkipArcadeNoWarnCS1591 to src/libraries/Directory.Build.props to avoid coreclr failures * Remove unnecessary slashes in sfxproj * Move SkipArcadeNoWarn up to the top of src/libraries/Directory.Build.props to ensure it gets loaded before importing arcade. * Revert Brotli and Vectors csproj changes. Those assemblies are either a partial facade or use PNSE. * Add target to intellisense.targets that runs as InitialTarget of the current project, and throws errors if the UseIntellisensePackageDocXmlFile is set to false and the assembly is either a partial facade or uses PNSE. * Improve error message: Mention the problematic property and the offending assembly. * Added extra condition to verification target to only run when UseIntellisense... is not set to true. Also moved the initial definition to its own solitary property group right before the verification target runs. Rename the properties that acquire the value of a file path to "FilePath" instead of just "File", for clarity. --------- Co-authored-by: smasher164 <akhilindurti@microsoft.com> Co-authored-by: carlossanlop <carlossanlop@users.noreply.github.com>
1 parent 58176f5 commit 0b3703e

9 files changed

Lines changed: 60 additions & 64 deletions

File tree

Build.proj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
</ItemGroup>
99

1010
<Import Project="$(RepositoryEngineeringDir)SubsetValidation.targets" />
11-
12-
<!-- Upfront restore hooks -->
13-
<Import Project="$(RepositoryEngineeringDir)restore\docs.targets" />
1411
<Import Project="$(RepositoryEngineeringDir)restore\optimizationData.targets" Condition="'$(DotNetBuildFromSource)' != 'true'" />
1512

1613
<Target Name="BuildLocalTasks"

Directory.Build.props

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@
105105
<IbcOptimizationDataDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsDir)', 'ibc'))</IbcOptimizationDataDir>
106106
<MibcOptimizationDataDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsDir)', 'mibc'))</MibcOptimizationDataDir>
107107
<XmlDocDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'docs'))</XmlDocDir>
108-
<XmlDocFileRoot>$([MSBuild]::NormalizeDirectory('$(NuGetPackageRoot)', 'microsoft.private.intellisense', '$(MicrosoftPrivateIntellisenseVersion)', 'IntellisenseFiles', 'net'))</XmlDocFileRoot>
109108
<DocsDir>$([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)', 'docs'))</DocsDir>
110109
<ManPagesDir>$([MSBuild]::NormalizeDirectory('$(DocsDir)', 'manpages'))</ManPagesDir>
111110

eng/intellisense.targets

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<Project InitialTargets="VerifyAssemblySupportsDocsXmlGeneration">
2+
3+
<PropertyGroup>
4+
<UseIntellisensePackageDocXmlFile Condition="'$(UseIntellisensePackageDocXmlFile)' == ''">true</UseIntellisensePackageDocXmlFile>
5+
</PropertyGroup>
6+
7+
<Target Name="VerifyAssemblySupportsDocsXmlGeneration"
8+
Condition="'$(UseIntellisensePackageDocXmlFile)' != 'true'">
9+
<Error
10+
Condition="'$(IsPartialFacadeAssembly)' == 'true'"
11+
Text="The 'UseIntellisensePackageDocXmlFile' property is not supported for partial facade assemblies: $(AssemblyName)" />
12+
<Error
13+
Condition="'$(GeneratePlatformNotSupportedAssemblyMessage)' != ''"
14+
Text="The 'UseIntellisensePackageDocXmlFile' property is not supported for assemblies that throw PlatformNotSupportedException: $(AssemblyName)" />
15+
</Target>
16+
17+
<PropertyGroup>
18+
<NoWarn Condition="'$(UseIntellisensePackageDocXmlFile)' == 'true'">$(NoWarn);1591</NoWarn>
19+
<IntellisensePackageXmlRootFolder>$([MSBuild]::NormalizeDirectory('$(NuGetPackageRoot)', 'microsoft.private.intellisense', '$(MicrosoftPrivateIntellisenseVersion)', 'IntellisenseFiles'))</IntellisensePackageXmlRootFolder>
20+
<IntellisensePackageXmlFilePathFromNetFolder>$([MSBuild]::NormalizePath('$(IntellisensePackageXmlRootFolder)', 'net', '1033', '$(AssemblyName).xml'))</IntellisensePackageXmlFilePathFromNetFolder>
21+
<IntellisensePackageXmlFilePathFromDotNetPlatExtFolder>$([MSBuild]::NormalizePath('$(IntellisensePackageXmlRootFolder)', 'dotnet-plat-ext', '1033', '$(AssemblyName).xml'))</IntellisensePackageXmlFilePathFromDotNetPlatExtFolder>
22+
<IntellisensePackageXmlFilePath Condition="'$(UseIntellisensePackageDocXmlFile)' == 'true' and Exists($(IntellisensePackageXmlFilePathFromNetFolder))">$(IntellisensePackageXmlFilePathFromNetFolder)</IntellisensePackageXmlFilePath>
23+
<IntellisensePackageXmlFilePath Condition="'$(IntellisensePackageXmlFilePath)' == '' and '$(UseIntellisensePackageDocXmlFile)' == 'true' and Exists($(IntellisensePackageXmlFilePathFromDotNetPlatExtFolder))">$(IntellisensePackageXmlFilePathFromDotNetPlatExtFolder)</IntellisensePackageXmlFilePath>
24+
</PropertyGroup>
25+
26+
<ItemGroup>
27+
<PackageDownload Include="Microsoft.Private.Intellisense" Version="[$(MicrosoftPrivateIntellisenseVersion)]" />
28+
</ItemGroup>
29+
30+
<!-- TODO: Remove this target when no library relies on the intellisense documentation file anymore.-->
31+
<!-- Replace the default xml file generated in the obj folder with the one that comes from the docs feed. -->
32+
<Target Name="ChangeDocumentationFileForPackaging"
33+
AfterTargets="DocumentationProjectOutputGroup"
34+
Condition="'$(UseIntellisensePackageDocXmlFile)' == 'true'">
35+
<ItemGroup>
36+
<DocFileItem Remove="@(DocFileItem)" />
37+
<DocFileItem Include="$(IntellisensePackageXmlFilePath)" />
38+
</ItemGroup>
39+
</Target>
40+
41+
<Target Name="CopyDocumentationFileToXmlDocDir"
42+
AfterTargets="CopyFilesToOutputDirectory"
43+
Condition="'$(IsNetCoreAppSrc)' == 'true' and '$(TargetFramework)' == '$(NetCoreAppCurrent)'"
44+
DependsOnTargets="ChangeDocumentationFileForPackaging">
45+
<Copy SourceFiles="@(DocFileItem)"
46+
DestinationFolder="$(XmlDocDir)"
47+
SkipUnchangedFiles="true"
48+
UseHardlinksIfPossible="true" />
49+
</Target>
50+
51+
</Project>

eng/packaging.targets

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@
2828
<GeneratePackageOnBuild Condition="'$(GeneratePackageOnBuild)' != 'true' and
2929
'$(BuildAllConfigurations)' == 'true' and
3030
'$(DotNetBuildFromSource)' == 'true'">true</GeneratePackageOnBuild>
31-
<!-- Search for the documentation file in the intellisense package and otherwise pick up the generated one. -->
32-
<LibIntellisenseDocumentationFilePath>$(XmlDocFileRoot)1033\$(AssemblyName).xml</LibIntellisenseDocumentationFilePath>
33-
<UseIntellisenseDocumentationFile Condition="'$(UseIntellisenseDocumentationFile)' == '' and Exists('$(LibIntellisenseDocumentationFilePath)')">true</UseIntellisenseDocumentationFile>
31+
3432
<!-- During NoBuild pack invocations, skip project reference build. Necessary for the IncludeProjectReferencesWithPackAttributeInPackage target. -->
3533
<BuildProjectReferences Condition="'$(NoBuild)' == 'true'">false</BuildProjectReferences>
3634
</PropertyGroup>
@@ -108,16 +106,6 @@
108106
($(TargetFrameworks.Contains('$(NetFrameworkMinimum)')) or $(TargetFrameworks.Contains('net47')) or $(TargetFrameworks.Contains('net48')))" />
109107
</ItemGroup>
110108

111-
<!-- TODO: Remove this target when no library relies on the intellisense documentation file anymore.-->
112-
<Target Name="ChangeDocumentationFileForPackaging"
113-
AfterTargets="DocumentationProjectOutputGroup"
114-
Condition="'$(UseIntellisenseDocumentationFile)' == 'true'">
115-
<ItemGroup>
116-
<DocumentationProjectOutputGroupOutput Remove="@(DocumentationProjectOutputGroupOutput)" />
117-
<DocumentationProjectOutputGroupOutput Include="$(LibIntellisenseDocumentationFilePath)" />
118-
</ItemGroup>
119-
</Target>
120-
121109
<!-- Add runtime specific file into the package if the tfm is RID specific. -->
122110
<Target Name="AddRuntimeSpecificFilesToPackage"
123111
DependsOnTargets="BuiltProjectOutputGroup;

eng/restore/docs.targets

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

src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Ref.sfxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<Target Name="AddFrameworkFilesToPackage" DependsOnTargets="ResolveLibrariesFromLocalBuild" BeforeTargets="GetFilesToPackage">
1515
<ItemGroup>
1616
<ReferencePath Include="@(LibrariesRefAssemblies)" />
17-
<DocFilesToPackage Include="$(ArtifactsBinDir)/docs/%(LibrariesRefAssemblies.FileName).xml" Condition="Exists('$(ArtifactsBinDir)/docs/%(LibrariesRefAssemblies.FileName).xml')"/>
17+
<DocFilesToPackage Include="$(XmlDocDir)%(LibrariesRefAssemblies.FileName).xml" Condition="Exists('$(XmlDocDir)%(LibrariesRefAssemblies.FileName).xml')"/>
1818
<Analyzer Include="$(MicrosoftNetCoreAppRefPackDir)/analyzers/**/*.*" />
1919
<FilesToPackage Include="@(Analyzer)" ExcludeFromValidation="true" TargetPath="analyzers/%(RecursiveDir)" />
2020
</ItemGroup>

src/libraries/Directory.Build.props

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
<PropertyGroup>
33
<SkipInferTargetOSName>true</SkipInferTargetOSName>
44
<DisableArcadeTestFramework>true</DisableArcadeTestFramework>
5+
<!-- Enabling this rule will cause build failures on undocumented public APIs.
6+
We cannot add it in eng/Versions.props because src/coreclr does not have access to UseIntellisensePackageDocXmlFile, which ensures
7+
we only enable it in specific projects. so to avoid duplicating this property in coreclr, we can first scope it to src/libraries.
8+
This property needs to be declared before the ..\..\Directory.Build.props import. -->
9+
<SkipArcadeNoWarnCS1591>true</SkipArcadeNoWarnCS1591>
510
</PropertyGroup>
611

712
<Import Project="..\..\Directory.Build.props" />

src/libraries/Directory.Build.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
</PropertyGroup>
7878

7979
<Import Project="$(RepositoryEngineeringDir)versioning.targets" />
80+
<Import Project="$(RepositoryEngineeringDir)intellisense.targets" Condition="'$(IsSourceProject)' == 'true'" />
8081

8182
<!-- Libraries-specific binplacing properties -->
8283
<PropertyGroup>

src/libraries/System.Formats.Cbor/src/System.Formats.Cbor.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<TargetFrameworks>$(NetCoreAppCurrent);$(NetCoreAppPrevious);$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum)</TargetFrameworks>
44
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
55
<IsPackable>true</IsPackable>
6+
<UseIntellisensePackageDocXmlFile>false</UseIntellisensePackageDocXmlFile>
67
<PackageDescription>Provides classes that can read and write the CBOR data format.
78

89
Commonly Used Types:

0 commit comments

Comments
 (0)