|
| 1 | +<Project Sdk="Microsoft.NET.Sdk"> |
| 2 | + |
| 3 | + <Import Project="$(RepositoryRoot)eng/nuget.props" /> |
| 4 | + |
| 5 | + <PropertyGroup> |
| 6 | + <!-- Note TargetFramework or TargetFrameworks must match the output projects for the directories to be build correctly --> |
| 7 | + <TargetFramework>netstandard2.0</TargetFramework> |
| 8 | + <GeneratePackageOnBuild>true</GeneratePackageOnBuild> |
| 9 | + <IncludeBuildOutput>false</IncludeBuildOutput> |
| 10 | + <IncludeSymbols>false</IncludeSymbols> |
| 11 | + |
| 12 | + <NoPackageAnalysis>true</NoPackageAnalysis> |
| 13 | + <DevelopmentDependency>true</DevelopmentDependency> |
| 14 | + </PropertyGroup> |
| 15 | + |
| 16 | + <PropertyGroup Label="NuGet Package Settings"> |
| 17 | + <PackageId>Lucene.Net.CodeAnalysis.Dev</PackageId> |
| 18 | + <Description>Analyzers and code fixes for Lucene.NET development.</Description> |
| 19 | + <PackageTags>$(PackageTags);code analysis;code maintenance;roslyn</PackageTags> |
| 20 | + <PackageOutputPath>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\..\_artifacts\NuGetPackages\$(Configuration)'))</PackageOutputPath> |
| 21 | + <_PackageVersionPropsFile>$(PackageOutputPath)\Lucene.Net.CodeAnalysis.Dev.Version.props</_PackageVersionPropsFile> |
| 22 | + </PropertyGroup> |
| 23 | + |
| 24 | + <PropertyGroup Label="NuGet Package File Paths"> |
| 25 | + <_CodeAnalysisCSAssemblyFile>$(RepositoryRoot)src\Lucene.Net.CodeAnalysis.Dev\bin\$(Configuration)\$(TargetFramework)\Lucene.Net.CodeAnalysis.Dev.dll</_CodeAnalysisCSAssemblyFile> |
| 26 | + <_CodeAnalysisCodeFixesCSAssemblyFile>$(RepositoryRoot)src\Lucene.Net.CodeAnalysis.Dev\bin\$(Configuration)\$(TargetFramework)\Lucene.Net.CodeAnalysis.Dev.CodeFixes.dll</_CodeAnalysisCodeFixesCSAssemblyFile> |
| 27 | + </PropertyGroup> |
| 28 | + |
| 29 | + <ItemGroup Label="Localized Resources"> |
| 30 | + <_CodeAnalyisisResources Include="$(RepositoryRoot)src\Lucene.Net.CodeAnalysis.Dev\bin\$(Configuration)\$(TargetFramework)\**\*.resources.dll" /> |
| 31 | + </ItemGroup> |
| 32 | + |
| 33 | + <ItemGroup Label="NuGet Package Files"> |
| 34 | + <None Include="$(_CodeAnalysisCSAssemblyFile)" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" /> |
| 35 | + |
| 36 | + <None Include="$(_CodeAnalysisCodeFixesCSAssemblyFile)" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" Condition="Exists('$(_CodeAnalysisCodeFixesCSAssemblyFile)')" /> |
| 37 | + |
| 38 | + <None Include="@(_CodeAnalyisisResources)" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" /> |
| 39 | + </ItemGroup> |
| 40 | + |
| 41 | + <ItemGroup> |
| 42 | + <!-- We only need this to ensure it is built before this project is. We include all dependent projects because |
| 43 | + it is required by the MSBuild target below. Granted, including only Lucene.Net.CodeAnalysis.Dev.csproj would work |
| 44 | + in normal scenarios, but when executing an MSBuild target from a consuming project (SPDX.CodeAnalysis.Sample.csproj), |
| 45 | + these are required to be built first and in the order that they are listed here. --> |
| 46 | + <ProjectReference Include="..\Lucene.Net.CodeAnalysis.Dev\Lucene.Net.CodeAnalysis.Dev.csproj" ReferenceOutputAssembly="false" /> |
| 47 | + <ProjectReference Include="..\Lucene.Net.CodeAnalysis.Dev\Lucene.Net.CodeAnalysis.Dev.CodeFixes.csproj" ReferenceOutputAssembly="false" Condition="Exists('..\Lucene.Net.CodeAnalysis.Dev\Lucene.Net.CodeAnalysis.Dev.CodeFixes.csproj')" /> |
| 48 | + </ItemGroup> |
| 49 | + |
| 50 | + <Target Name="EnsureDependenciesBuilt" BeforeTargets="PrepareForBuild"> |
| 51 | + <MSBuild Projects="@(ProjectReference)" Targets="Restore;PrepareForBuild;Build" Properties="Configuration=$(Configuration)" BuildInParallel="false" /> |
| 52 | + </Target> |
| 53 | + |
| 54 | + <UsingTask TaskName="GenerateVersionProps" TaskFactory="RoslynCodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll"> |
| 55 | + |
| 56 | + <ParameterGroup> |
| 57 | + <OutputFile ParameterType="System.String" Required="true" /> |
| 58 | + <Version ParameterType="System.String" Required="true" /> |
| 59 | + </ParameterGroup> |
| 60 | + |
| 61 | + <Task> |
| 62 | + <Using Namespace="System.Xml" /> |
| 63 | + <Code Type="Fragment" Language="cs"> |
| 64 | + <![CDATA[ |
| 65 | + var trimmedVersion = Version.Trim(); |
| 66 | + var settings = new XmlWriterSettings { Indent = true }; |
| 67 | + using (var writer = XmlWriter.Create(OutputFile, settings)) |
| 68 | + { |
| 69 | + writer.WriteStartDocument(); |
| 70 | + writer.WriteStartElement("Project"); |
| 71 | + writer.WriteStartElement("PropertyGroup"); |
| 72 | + writer.WriteElementString("_CodeAnalysisPackageVersion", trimmedVersion); |
| 73 | + writer.WriteEndElement(); // PropertyGroup |
| 74 | + writer.WriteEndElement(); // Project |
| 75 | + writer.WriteEndDocument(); |
| 76 | + } |
| 77 | + ]]> |
| 78 | + </Code> |
| 79 | + </Task> |
| 80 | + </UsingTask> |
| 81 | + |
| 82 | + <Target Name="AppendDebugTimestampToPackageVersion" |
| 83 | + AfterTargets="GetBuildVersion"> |
| 84 | + <PropertyGroup Condition="'$(Configuration)' == 'Debug'"> |
| 85 | + <!-- Append timestamp every ~2 seconds --> |
| 86 | + <PackageVersion> |
| 87 | + $(PackageVersion)-debug-$([System.DateTime]::UtcNow.DayOfYear)-$([System.Math]::Floor($([System.DateTime]::UtcNow.TimeOfDay.TotalSeconds))) |
| 88 | + </PackageVersion> |
| 89 | + </PropertyGroup> |
| 90 | + </Target> |
| 91 | + |
| 92 | + <Target Name="GeneratePackageVersionProps" DependsOnTargets="GetBuildVersion" AfterTargets="BeforeBuild"> |
| 93 | + <MakeDir Directories="$(PackageOutputPath)" Condition="!Exists('$(PackageOutputPath)')" /> |
| 94 | + |
| 95 | + <GenerateVersionProps OutputFile="$(_PackageVersionPropsFile)" Version="$(PackageVersion)" /> |
| 96 | + </Target> |
| 97 | + |
| 98 | + <Target Name="CleanNuGetPackagesDirectory" AfterTargets="Clean"> |
| 99 | + <ItemGroup> |
| 100 | + <__NuGetFilePaths Include="$(PackageOutputPath)\*.nupkg" /> |
| 101 | + </ItemGroup> |
| 102 | + |
| 103 | + <Delete Files="@(__NuGetFilePaths);$(_PackageVersionPropsFile)" /> |
| 104 | + </Target> |
| 105 | + |
| 106 | +</Project> |
0 commit comments