Skip to content

Commit

Permalink
Fix xml intellisense generation (#154)
Browse files Browse the repository at this point in the history
Make sure the commited intellisense xml files are correctly included in the nupkgs, while also preventing them from getting rewritten on every build.
  • Loading branch information
carlossanlop authored Nov 5, 2024
1 parent 5aba9a6 commit 9c51360
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 14 deletions.
5 changes: 5 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
<BeforeTargetFrameworkInferenceTargets>$(RepositoryEngineeringDir)BeforeTargetFrameworkInference.targets</BeforeTargetFrameworkInferenceTargets>
<!-- Only upgrade NuGetAudit warnings to errors for official builds. -->
<WarningsNotAsErrors Condition="'$(OfficialBuild)' != 'true'">$(WarningsNotAsErrors);NU1901;NU1902;NU1903;NU1904</WarningsNotAsErrors>
<IsSourceProject Condition="'$(IsSourceProject)' == '' and
'$(IsTestProject)' != 'true' and
'$(UsingMicrosoftTraversalSdk)' != 'true'">true</IsSourceProject>
<!-- Prevent generating docs xmls from triple slash. Use the commited xml files instead. -->
<GenerateDocumentationFile>false</GenerateDocumentationFile>
</PropertyGroup>

</Project>
27 changes: 14 additions & 13 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,9 @@
<DefaultExcludesInProjectFolder Condition="'$(TargetFrameworkIdentifier)' != '.NETFramework'">$(DefaultExcludesInProjectFolder);**/*.netframework$(DefaultLanguageSourceExtension)</DefaultExcludesInProjectFolder>
</PropertyGroup>

<PropertyGroup>
<IsSourceProject Condition="'$(IsSourceProject)' == '' and
'$(IsTestProject)' != 'true' and
'$(UsingMicrosoftTraversalSdk)' != 'true'">true</IsSourceProject>
<CLSCompliant Condition="'$(CLSCompliant)' == '' and '$(IsSourceProject)' == 'true' and '$(MSBuildProjectExtension)' != '.ilproj'">true</CLSCompliant>
</PropertyGroup>

<PropertyGroup Condition="'$(IsTestProject)' == 'true'">
<!-- Suppress "CS1591 - Missing XML comment for publicly visible type or member" in tests. -->
<NoWarn>$(NoWarn);CS1573</NoWarn>
<!-- Don't run .NET Framework only tests on non Windows. -->
<SkipTests Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework' and '$(OS)' != 'Windows_NT'">true</SkipTests>
<!-- Make sure the target platform identifier matches the OS for running tests. -->
Expand All @@ -31,11 +26,10 @@
<!-- Unsafe code is required by PlatformDetection. -->
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

<PropertyGroup Condition="'$(IsSourceProject)' == 'true'">
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<DocumentationFile>$(MSBuildProjectDirectory)\$(AssemblyName).xml</DocumentationFile>

<PropertyGroup Condition="'$(IsSourceProject)' == 'true'">
<XmlDocumentationFilePath>$(MSBuildProjectDirectory)\$(AssemblyName).xml</XmlDocumentationFilePath>
<CLSCompliant Condition="'$(CLSCompliant)' == '' and '$(MSBuildProjectExtension)' != '.ilproj'">true</CLSCompliant>
<Description Condition="'$(Description)' == ''">$(AssemblyName)</Description>
<PackageDescription Condition="'$(PackageDescription)' == ''">$(AssemblyName)</PackageDescription>
</PropertyGroup>
Expand All @@ -56,8 +50,8 @@
</ItemGroup>

<ItemGroup Condition="'$(IsSourceProject)' == 'true'">
<None Include="$(DocumentationFile)" CopyToOutputDirectory="PreserveNewest" />

<!-- Ensures docs xmls get copied to the artifacts bin output folder. -->
<None Include="$(XmlDocumentationFilePath)" CopyToOutputDirectory="PreserveNewest" />
<AssemblyAttribute Include="System.CLSCompliantAttribute" Condition="'$(CLSCompliant)' == 'true'">
<_Parameter1>true</_Parameter1>
</AssemblyAttribute>
Expand Down Expand Up @@ -91,4 +85,11 @@
Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder);@(Compile)" />
</ItemGroup>

<!-- Include docs xmls in the final packages. -->
<Target Name="AddDocumentationFileForPackaging" AfterTargets="DocumentationProjectOutputGroup">
<ItemGroup>
<DocumentationProjectOutputGroupOutput Include="$(XmlDocumentationFilePath)" />
</ItemGroup>
</Target>

</Project>
11 changes: 11 additions & 0 deletions src/System.Data.SqlClient/tests/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project>

<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.props, $(MSBuildThisFileDirectory)..))" />

<PropertyGroup>
<!-- Workaround: There are many .csprojs under this tests directory which do not meet
the criteria of IsTestProject but still meet the criteria of IsSourceProject. -->
<IsSourceProject>false</IsSourceProject>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

Commonly Used Types:
System.Runtime.CompilerServices.Unsafe</PackageDescription>
<DocumentationFile>$(MSBuildProjectDirectory)\$(AssemblyName).xml</DocumentationFile>
</PropertyGroup>

<!-- VersionPrefix and IsPackable are defined in the parent folder's Versioning.props file. -->
Expand All @@ -37,7 +38,7 @@ System.Runtime.CompilerServices.Unsafe</PackageDescription>
</PropertyGroup>

<ItemGroup>
<DocFileItem Include="$(DocumentationFile)" Condition="'$(DocumentationFile)'!=''"/>
<DocFileItem Include="$(DocumentationFile)" Condition="'$(DocumentationFile)' != ''"/>
<!-- mscorlib is passed in as an explicit reference from C# targets but not via the IL SDK. -->
<Reference Include="$(CoreAssembly)" Condition="'$(TargetFramework)' == '$(NetFrameworkMinimum)'" />
<Compile Remove="System.Runtime.CompilerServices.Unsafe.il" Condition="'$(IsPlaceholderTargetFramework)' == 'true'" />
Expand Down

0 comments on commit 9c51360

Please sign in to comment.