Skip to content

Commit 1026e0f

Browse files
committed
Added Dirctory.Build.props, Directory.Build.targets. and Directory.Packages.props files to share common settings and enable Central Package Management.
1 parent 1163543 commit 1026e0f

9 files changed

Lines changed: 179 additions & 16 deletions

Directory.Build.props

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<Project>
2+
3+
<PropertyGroup>
4+
<RepositoryRoot>$(MSBuildThisFileDirectory)</RepositoryRoot>
5+
<LangVersion>12.0</LangVersion>
6+
<GitHubOrganization>apache</GitHubOrganization>
7+
<GitHubProject>lucenenet-codeanalysis-dev</GitHubProject>
8+
</PropertyGroup>
9+
10+
<PropertyGroup Label="Debug Settings">
11+
<DebugType>full</DebugType>
12+
</PropertyGroup>
13+
14+
<PropertyGroup Label="Version Settings">
15+
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
16+
</PropertyGroup>
17+
18+
<PropertyGroup Label="Nerdbank.GitVersioning Settings">
19+
<NBGV_EmitThisAssemblyClass>false</NBGV_EmitThisAssemblyClass>
20+
</PropertyGroup>
21+
22+
<PropertyGroup Label="NuGet Package Defaults">
23+
<IsPackable>false</IsPackable>
24+
</PropertyGroup>
25+
26+
<PropertyGroup Label="Assembly Signing">
27+
<AssemblyOriginatorKeyFile>$(RepositoryRoot)Lucene.Net.snk</AssemblyOriginatorKeyFile>
28+
<PublicKey>002400000480000094000000060200000024000052534131000400000100010075a07ce602f88ef263c7db8cb342c58ebd49ecdcc210fac874260b0213fb929ac3dcaf4f5b39744b800f99073eca72aebfac5f7284e1d5f2c82012a804a140f06d7d043d83e830cdb606a04da2ad5374cc92c0a49508437802fb4f8fb80a05e59f80afb99f4ccd0dfe44065743543c4b053b669509d29d332cd32a0cb1e97e84</PublicKey>
29+
<SignAssembly>true</SignAssembly>
30+
</PropertyGroup>
31+
32+
<PropertyGroup Label="Assembly Publishing">
33+
<IsPublishable>false</IsPublishable>
34+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
35+
</PropertyGroup>
36+
37+
<PropertyGroup Label="Copyright Info">
38+
<Product>Lucene.Net</Product>
39+
<Company>The Apache Software Foundation</Company>
40+
<CurrentYear Condition=" '$(CurrentYear)' == '' ">$([System.DateTime]::UtcNow.Year.ToString())</CurrentYear>
41+
<BeginCopyrightYear>2025</BeginCopyrightYear>
42+
<CopyrightYearRange>$(BeginCopyrightYear) - $(CurrentYear)</CopyrightYearRange>
43+
<CopyrightYearRange Condition=" '$(BeginCopyrightYear)' == '$(CurrentYear)' ">$(CurrentYear)</CopyrightYearRange>
44+
<Copyright>Copyright © $(CopyrightYearRange) $(Company)</Copyright>
45+
</PropertyGroup>
46+
47+
<PropertyGroup Label="SourceLink Settings: https://github.com/dotnet/sourcelink/blob/main/README.md">
48+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
49+
<EmbedUntrackedSources>true</EmbedUntrackedSources>
50+
</PropertyGroup>
51+
52+
<PropertyGroup Condition=" '$(BUILD_REPOSITORY_PROVIDER)' == 'GitHub' Or '$(BUILD_REPOSITORY_PROVIDER)' == 'TfsGit' " Label="Deterministic builds: https://github.com/clairernovotny/DeterministicBuilds#readme">
53+
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
54+
</PropertyGroup>
55+
56+
<PropertyGroup Label="Fake Folder Projects" Condition="'$(MSBuildProjectExtension)' == '.folderproj'">
57+
<!-- Required, but irrelevant -->
58+
<TargetFramework>netstandard2.0</TargetFramework>
59+
60+
<!-- Redirect output so it doesn't end up in the main folder. -->
61+
<BaseOutputPath>$(MSBuildThisFileDirectory)..\_artifacts\noop\$(MSBuildProjectName)\bin\</BaseOutputPath>
62+
<BaseIntermediateOutputPath>$(MSBuildThisFileDirectory)..\_artifacts\noop\$(MSBuildProjectName)\obj\</BaseIntermediateOutputPath>
63+
<OutputPath>$(BaseOutputPath)</OutputPath>
64+
<IntermediateOutputPath>$(BaseIntermediateOutputPath)</IntermediateOutputPath>
65+
66+
<!-- Do not run on solution builds -->
67+
<OutputType>None</OutputType>
68+
<BuildProjectReferences>false</BuildProjectReferences>
69+
<SkipBuild>true</SkipBuild>
70+
<SkipGitVersioning>true</SkipGitVersioning>
71+
</PropertyGroup>
72+
73+
</Project>

Directory.Build.targets

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<Project>
2+
3+
<Target Name="AddInternalsVisibleTo" BeforeTargets="BeforeCompile" Label="Adds InternalsVisibleTo Attribute and PublicKey (if supplied)">
4+
<ItemGroup Condition="'@(InternalsVisibleTo->Count())' &gt; 0 ">
5+
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
6+
<_Parameter1>%(InternalsVisibleTo.Identity)</_Parameter1>
7+
<_Parameter1 Condition=" '$(SignAssembly)' == 'true' And '$(PublicKey)' != '' ">%(InternalsVisibleTo.Identity), PublicKey=$(PublicKey)</_Parameter1>
8+
</AssemblyAttribute>
9+
</ItemGroup>
10+
</Target>
11+
12+
<Target Name="PrintTargetFrameworks" Label="Prints the value for the $(TargetFrameworks) property or 'none' if no frameworks apply. Pass TestProjectsOnly=true to get results only if this is a test project.">
13+
<PropertyGroup>
14+
<DoOutputTargetFrameworks Condition=" '$(TestProjectsOnly)' != 'true' Or ('$(TestProjectsOnly)' == 'true' And '$(IsTestProject)' == 'true')">true</DoOutputTargetFrameworks>
15+
<OutputTargetFrameworks Condition=" '$(DoOutputTargetFrameworks)' == 'true' ">$(TargetFramework)</OutputTargetFrameworks>
16+
<!-- Fallback to TargetFrameworks field if TargetFramework is empty -->
17+
<OutputTargetFrameworks Condition=" '$(DoOutputTargetFrameworks)' == 'true' And '$(OutputTargetFrameworks)' == '' ">$(TargetFrameworks)</OutputTargetFrameworks>
18+
<OutputTargetFrameworks Condition=" '$(OutputTargetFrameworks)' == '' ">none</OutputTargetFrameworks>
19+
</PropertyGroup>
20+
<Message Text="$(OutputTargetFrameworks)" Importance="high"/>
21+
</Target>
22+
23+
<ItemGroup Condition=" '$(SkipGitVersioning.ToLower())' != 'true' ">
24+
<PackageReference Include="Nerdbank.GitVersioning" PrivateAssets="All" />
25+
</ItemGroup>
26+
27+
</Project>

Directory.Packages.props

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<Project>
2+
<PropertyGroup Label="Central Package Management Settings">
3+
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
4+
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
5+
</PropertyGroup>
6+
7+
<PropertyGroup Label="Shared NuGet Package Reference Versions">
8+
<RoslynAnalyzerPackageVersion>4.14.0</RoslynAnalyzerPackageVersion>
9+
</PropertyGroup>
10+
11+
<ItemGroup Label="NuGet Package Reference Versions">
12+
<PackageVersion Include="Nerdbank.GitVersioning" Version="3.7.115" />
13+
<PackageVersion Include="NUnit" Version="4.4.0" />
14+
<PackageVersion Include="NUnit3TestAdapter" Version="5.1.0" />
15+
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0" />
16+
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzer.Testing" Version="1.1.2" />
17+
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="$(RoslynAnalyzerPackageVersion)" />
18+
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="$(RoslynAnalyzerPackageVersion)" />
19+
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Features" Version="$(RoslynAnalyzerPackageVersion)" />
20+
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="$(RoslynAnalyzerPackageVersion)" />
21+
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic" Version="$(RoslynAnalyzerPackageVersion)" />
22+
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic.Features" Version="$(RoslynAnalyzerPackageVersion)" />
23+
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic.Workspaces" Version="$(RoslynAnalyzerPackageVersion)" />
24+
<PackageVersion Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="$(RoslynAnalyzerPackageVersion)" />
25+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
26+
<PackageVersion Include="Microsoft.VSSDK.BuildTools" Version="17.14.2094" />
27+
</ItemGroup>
28+
29+
</Project>

src/Directory.Build.props

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Project>
2+
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
3+
</Project>

src/Directory.Build.targets

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project>
2+
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.targets', '$(MSBuildThisFileDirectory)../'))" />
3+
4+
<PropertyGroup Label="Assembly Documentation">
5+
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
6+
</PropertyGroup>
7+
8+
</Project>

src/Lucene.Net.CodeAnalysis.Dev/Lucene.Net.CodeAnalysis.Dev.csproj

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,20 @@
33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
55
<Nullable>enable</Nullable>
6-
<LangVersion>latest</LangVersion>
6+
7+
<!-- Newer versions of VS and the SDK allow loading as 64 bit, so we need this for compatibility when loading in VS -->
8+
<Prefer32Bit>false</Prefer32Bit>
9+
710
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
811
<IsRoslynComponent>true</IsRoslynComponent>
9-
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
10-
<IncludeBuildOutput>false</IncludeBuildOutput>
11-
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
12+
<!--<TreatWarningsAsErrors>true</TreatWarningsAsErrors>-->
13+
14+
<!-- Avoid ID conflicts with the package project. -->
15+
<PackageId>*$(MSBuildProjectFile)*</PackageId>
16+
17+
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
18+
<EnableNativeCodeDebugging>true</EnableNativeCodeDebugging>
19+
1220
<NoPackageAnalysis>true</NoPackageAnalysis>
1321
<DevelopmentDependency>true</DevelopmentDependency>
1422

@@ -20,11 +28,11 @@
2028
</PropertyGroup>
2129

2230
<ItemGroup>
23-
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0">
31+
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers">
2432
<PrivateAssets>all</PrivateAssets>
2533
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2634
</PackageReference>
27-
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.12.0" />
35+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" />
2836
</ItemGroup>
2937

3038
<ItemGroup>
@@ -44,14 +52,14 @@
4452
</EmbeddedResource>
4553
</ItemGroup>
4654

47-
<PropertyGroup Label="Assembly Signing">
48-
<AssemblyOriginatorKeyFile>$(SolutionDir)Lucene.Net.snk</AssemblyOriginatorKeyFile>
49-
<PublicKey>002400000480000094000000060200000024000052534131000400000100010075a07ce602f88ef263c7db8cb342c58ebd49ecdcc210fac874260b0213fb929ac3dcaf4f5b39744b800f99073eca72aebfac5f7284e1d5f2c82012a804a140f06d7d043d83e830cdb606a04da2ad5374cc92c0a49508437802fb4f8fb80a05e59f80afb99f4ccd0dfe44065743543c4b053b669509d29d332cd32a0cb1e97e84</PublicKey>
50-
<SignAssembly>true</SignAssembly>
51-
</PropertyGroup>
52-
5355
<ItemGroup>
5456
<None Include="$(OutputPath)\$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
5557
</ItemGroup>
58+
59+
<!-- See: https://github.com/dotnet/roslyn-analyzers/issues/5663#issuecomment-948304565 -->
60+
<ItemGroup>
61+
<AdditionalFiles Include="AnalyzerReleases.Shipped.md" />
62+
<AdditionalFiles Include="AnalyzerReleases.Unshipped.md" />
63+
</ItemGroup>
5664

5765
</Project>

tests/Directory.Build.props

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project>
2+
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
3+
4+
<!--<PropertyGroup Label="Code Coverage Settings">
5+
<Exclude>[*.Tests]*,[*]NUnit3.TestAdapter.*,[*]Microsoft.CodeAnalysis.Analyzer.Testing.*</Exclude>
6+
<ExcludeByFile>**/*Tests*.cs</ExcludeByFile>
7+
</PropertyGroup>-->
8+
</Project>

tests/Directory.Build.targets

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<Project>
2+
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.targets', '$(MSBuildThisFileDirectory)../'))" />
3+
4+
<!-- These will be referenced only for projects where IsTestProject == true -->
5+
<ItemGroup Condition="'$(IsTestProject)' == 'true'">
6+
<PackageReference Include="Microsoft.NET.Test.Sdk" />
7+
<PackageReference Include="NUnit" />
8+
<PackageReference Include="NUnit3TestAdapter" />
9+
</ItemGroup>
10+
</Project>

tests/Lucene.Net.CodeAnalysis.Dev.Tests/Lucene.Net.CodeAnalysis.Dev.Tests.csproj

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.13.0" />
10-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
11-
<PackageReference Include="NUnit" Version="4.3.2" />
12-
<PackageReference Include="NUnit3TestAdapter" Version="5.0.0" />
9+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" />
1310
</ItemGroup>
1411

1512
<ItemGroup>

0 commit comments

Comments
 (0)