Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Directory.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<PropertyGroup Label="NuGet">
<PackageTags>dotnet roslyn</PackageTags>
<PackOnBuild>true</PackOnBuild>
<DevelopmentDependency>true</DevelopmentDependency>
<ThisAssemblyMinimumRoslynVersion>4.0</ThisAssemblyMinimumRoslynVersion>
<PackFolder>analyzers/dotnet/roslyn$(ThisAssemblyMinimumRoslynVersion)/cs</PackFolder>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
Expand All @@ -18,6 +19,8 @@

<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
<NoWarn>MSB3277;$(NoWarn)</NoWarn>

<Product>ThisAssembly</Product>
</PropertyGroup>

<PropertyGroup Label="Build">
Expand Down
52 changes: 51 additions & 1 deletion src/Directory.targets
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project>
<Project InitialTargets="SetLocalVersion">

<ItemGroup>
<None Update="@(None)" CopyToOutputDirectory="PreserveNewest" />
Expand All @@ -9,4 +9,54 @@
<PackageFile Include="*.props;*.targets" PackagePath="build\$(TargetFramework)\%(Filename)%(Extension)" Visible="true" />
</ItemGroup>

<Target Name="PackCopyLocalLockFileAssemblies" Condition="'$(MergeAnalyzerAssemblies)' != 'true'" BeforeTargets="GetPackageContents" DependsOnTargets="ReferenceCopyLocalPathsOutputGroup">
<ItemGroup>
<ReferenceCopyLocalAssemblies Include="@(ReferenceCopyLocalPaths)" Condition="'%(Extension)' == '.dll'
And !$([MSBuild]::ValueOrDefault('%(FileName)', '').EndsWith('.resources', StringComparison.OrdinalIgnoreCase))
And !$([MSBuild]::ValueOrDefault('%(FileName)', '').StartsWith('ThisAssembly', StringComparison.OrdinalIgnoreCase))" />
<PackCopyLocalAssemblies Include="@(ReferenceCopyLocalAssemblies)" Condition="
!$([MSBuild]::ValueOrDefault('%(FileName)', '').StartsWith('Microsoft.CodeAnalysis', StringComparison.OrdinalIgnoreCase)) And
!$([MSBuild]::ValueOrDefault('%(FileName)', '').StartsWith('Microsoft.CSharp', StringComparison.OrdinalIgnoreCase)) And
!$([MSBuild]::ValueOrDefault('%(FileName)', '').StartsWith('System.', StringComparison.OrdinalIgnoreCase))"
/>
<!-- Brings in System/Microsoft.IdentityModel, System.Text.Encodings.Web, System.Text.Json -->
<PackCopyLocalAssemblies Include="@(ReferenceCopyLocalAssemblies)" Condition="
$([MSBuild]::ValueOrDefault('%(FileName)', '').StartsWith('System.IdentityModel', StringComparison.OrdinalIgnoreCase)) Or
$([MSBuild]::ValueOrDefault('%(FileName)', '').StartsWith('Microsoft.IdentityModel', StringComparison.OrdinalIgnoreCase)) Or
$([MSBuild]::ValueOrDefault('%(FileName)', '').StartsWith('System.Text', StringComparison.OrdinalIgnoreCase))"
/>
<PackageFile Include="@(PackCopyLocalAssemblies)" PackFolder="$(PackFolder)" />
</ItemGroup>
</Target>

<Target Name="SetLocalVersion" Condition="!$(CI)">
<GetVersion>
<Output TaskParameter="Version" PropertyName="Version" />
</GetVersion>
</Target>

<UsingTask TaskName="GetVersion" TaskFactory="RoslynCodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<Version Output="true" />
</ParameterGroup>
<Task>
<Using Namespace="System" />
<Using Namespace="Microsoft.Build.Framework"/>
<Code Type="Fragment" Language="cs">
<![CDATA[
var version = this.BuildEngine4.GetRegisteredTaskObject("Version", RegisteredTaskObjectLifetime.Build);
if (version == null)
{
var epoc = DateTime.Parse("2024-03-15");
var days = Math.Truncate(DateTime.UtcNow.Subtract(epoc).TotalDays);
var time = Math.Floor(DateTime.UtcNow.TimeOfDay.TotalMinutes);
version = "42." + days + "." + time;
this.BuildEngine4.RegisterTaskObject("Version", version, RegisteredTaskObjectLifetime.Build, false);
}
Version = (string)version;
]]>
</Code>
</Task>
</UsingTask>

</Project>
10 changes: 1 addition & 9 deletions src/Shared/Shared.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)**/*$(DefaultLanguageSourceExtension)" Source="Shared" />
<EmbeddedResource Include="$(MSBuildThisFileDirectory)**/*.resx" Source="Shared" />
<None Include="$(MSBuildThisFileDirectory)**/*" Exclude="$(MSBuildThisFileDirectory)*.projitems;$(MSBuildThisFileDirectory)*.shproj" Source="Shared" />
<None Remove="$(MSBuildThisFileDirectory)**/*$(DefaultLanguageSourceExtension)" />
<None Include="$(MSBuildThisFileDirectory)**/*" Exclude="$(MSBuildThisFileDirectory)*.projitems;$(MSBuildThisFileDirectory)*.shproj" Source="Shared" /> <None Remove="$(MSBuildThisFileDirectory)**/*$(DefaultLanguageSourceExtension)" />
<None Remove="$(MSBuildThisFileDirectory)**/*.resx" />
</ItemGroup>
<ItemGroup>
Expand All @@ -21,11 +20,4 @@
<Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
</None>
</ItemGroup>
<ItemGroup>
<!-- Add prerequisites to package -->
<None Update="$(MSBuildThisFileDirectory)*.props;$(MSBuildThisFileDirectory)*.targets" Condition="'$(PackSharedTargets)' != 'false'">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<PackagePath>build\$(TargetFramework)\%(Filename)%(Extension)</PackagePath>
</None>
</ItemGroup>
</Project>
6 changes: 0 additions & 6 deletions src/Shared/Shared.shproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,4 @@
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
<Import Project="Shared.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
<ItemGroup>
<PackageFile Remove="ThisAssembly.Prerequisites.targets" />
</ItemGroup>
<ItemGroup>
<UpToDateCheck Remove="ThisAssembly.Prerequisites.targets" />
</ItemGroup>
</Project>
33 changes: 0 additions & 33 deletions src/Shared/ThisAssembly.Prerequisites.targets

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>latest</LangVersion>
<IsRoslynComponent>true</IsRoslynComponent>
<CustomAfterMicrosoftCSharpTargets>$(MSBuildThisFileDirectory)..\SponsorLink\SponsorLink.targets</CustomAfterMicrosoftCSharpTargets>
</PropertyGroup>

<PropertyGroup>
Expand All @@ -27,9 +28,7 @@ on the `ThisAssembly.Info` class.
</PropertyGroup>

<ItemGroup>
<!--<PackageReference Include="Devlooped.SponsorLink" Version="1.0.0" />-->
<PackageReference Include="NuGetizer" Version="1.2.2" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="all" />

<PackageReference Include="Scriban" Version="5.10.0" Pack="false" IncludeAssets="build" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project>
<Import Project="..\buildTransitive\Devlooped.Sponsors.targets" Condition="Exists('..\buildTransitive\Devlooped.Sponsors.targets')"/>

<ItemGroup>
<!-- Make sure we're always private to the referencing project.
Prevents analyzers from "flowing out" of the referencing project. -->
<PackageReference Update="ThisAssembly.AssemblyInfo" PrivateAssets="all" PackTransitive="false" />
</ItemGroup>

<Import Condition="'$(ThisAssemblyPrerequisitesImported)' != 'true'" Project="ThisAssembly.Prerequisites.targets" />
</Project>
3 changes: 1 addition & 2 deletions src/ThisAssembly.Constants/ConstantsGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
.Where(x =>
x.Right.GetOptions(x.Left).TryGetValue("build_metadata.AdditionalFiles.SourceItemType", out var itemType)
&& itemType == "Constant")
.Where(x => x.Right.GetOptions(x.Left).TryGetValue("build_metadata.Constant.Value", out var value) && value != null)
.Select((x, ct) =>
{
x.Right.GetOptions(x.Left).TryGetValue("build_metadata.Constant.Value", out var value);
Expand All @@ -32,7 +31,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context)

return (
name: Path.GetFileName(x.Left.Path),
value: value!,
value: value ?? "",
comment: string.IsNullOrWhiteSpace(comment) ? null : comment,
root: string.IsNullOrWhiteSpace(root) ? "Constants" : root!);
})
Expand Down
9 changes: 2 additions & 7 deletions src/ThisAssembly.Constants/ThisAssembly.Constants.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>latest</LangVersion>
<IsRoslynComponent>true</IsRoslynComponent>
<CustomAfterMicrosoftCSharpTargets>$(MSBuildThisFileDirectory)..\SponsorLink\SponsorLink.targets</CustomAfterMicrosoftCSharpTargets>
</PropertyGroup>

<PropertyGroup>
Expand Down Expand Up @@ -39,17 +40,11 @@ C#:

<ItemGroup>
<None Remove="CSharp.sbntxt" />
<None Remove="ThisAssembly.Constants.targets" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="CSharp.sbntxt" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

<ItemGroup>
<!--<PackageReference Include="Devlooped.SponsorLink" Version="1.0.0" />-->
<PackageReference Include="NuGetizer" Version="1.2.2" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="all" />

<PackageReference Include="Scriban" Version="5.10.0" Pack="false" IncludeAssets="build" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
Expand Down
2 changes: 1 addition & 1 deletion src/ThisAssembly.Constants/ThisAssembly.Constants.targets
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<Project>
<Import Project="..\buildTransitive\Devlooped.Sponsors.targets" Condition="Exists('..\buildTransitive\Devlooped.Sponsors.targets')"/>

<ItemGroup>
<CompilerVisibleItemMetadata Include="AdditionalFiles" MetadataName="SourceItemType" />
Expand Down Expand Up @@ -53,5 +54,4 @@
</ItemGroup>
</Target>

<Import Condition="'$(ThisAssemblyPrerequisitesImported)' != 'true'" Project="ThisAssembly.Prerequisites.targets" />
</Project>
4 changes: 1 addition & 3 deletions src/ThisAssembly.Git/ThisAssembly.Git.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
Expand Down Expand Up @@ -30,9 +30,7 @@
</ItemGroup>

<ItemGroup>
<!--<PackageReference Include="Devlooped.SponsorLink" Version="1.0.0" />-->
<PackageReference Include="NuGetizer" Version="1.2.2" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="all" />
</ItemGroup>

<Import Project="..\Shared\Shared.projitems" Label="Shared" />
Expand Down
13 changes: 6 additions & 7 deletions src/ThisAssembly.Git/ThisAssembly.Git.targets
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<SourceLinkUrl>@(_ThisAssemblyGitSourceRoot -> '%(SourceLinkUrl)')</SourceLinkUrl>
</PropertyGroup>

<Warning Code="THIS002" Text="A valid SourceLink provider does not seem to be installed for the current repository/project. Values will be empty." Condition="'$(SourceLinkUrl)' == ''" />
<Warning Code="TA001" Text="A valid SourceLink provider does not seem to be installed for the current repository/project. Some values may be empty." Condition="'$(SourceLinkUrl)' == ''" />

<PropertyGroup Condition="'$(RepositoryBranch)' == '' and '$(RepositoryRoot)' != ''">
<!-- We may not be in CI at all. If we got a git repo root, we can directly read HEAD -->
Expand All @@ -81,11 +81,11 @@
<EmptySourceControlValue>[pending build]</EmptySourceControlValue>
</PropertyGroup>
<ItemGroup Condition="'$(EnableSourceControlManagerQueries)' != 'true'">
<Constant Include="Branch" Value="[pending build]" Root="Git" />
<Constant Include="Commit" Value="[pending build]" Root="Git" />
<Constant Include="Sha" Value="[pending build]" Root="Git" />
<Constant Include="Root" Value="[pending build]" Root="Git" />
<Constant Include="Url" Value="[pending build]" Root="Git" />
<Constant Include="Branch" Value="$(EmptySourceControlValue)" Root="Git" />
<Constant Include="Commit" Value="$(EmptySourceControlValue)" Root="Git" />
<Constant Include="Sha" Value="$(EmptySourceControlValue)" Root="Git" />
<Constant Include="Root" Value="$(EmptySourceControlValue)" Root="Git" />
<Constant Include="Url" Value="$(EmptySourceControlValue)" Root="Git" />
</ItemGroup>
<ItemGroup Condition="'$(EnableSourceControlManagerQueries)' == 'true'">
<Constant Include="Branch" Value="$(RepositoryBranch)" Root="Git" />
Expand All @@ -96,5 +96,4 @@
</ItemGroup>
</Target>

<Import Condition="'$(ThisAssemblyPrerequisitesImported)' != 'true'" Project="ThisAssembly.Prerequisites.targets" />
</Project>
4 changes: 1 addition & 3 deletions src/ThisAssembly.Metadata/ThisAssembly.Metadata.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
Expand Down Expand Up @@ -44,9 +44,7 @@ C#:
</ItemGroup>

<ItemGroup>
<!--<PackageReference Include="Devlooped.SponsorLink" Version="1.0.0" />-->
<PackageReference Include="NuGetizer" Version="1.2.2" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
Expand Down
1 change: 0 additions & 1 deletion src/ThisAssembly.Metadata/ThisAssembly.Metadata.targets
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@
</ItemGroup>
</Target>

<Import Condition="'$(ThisAssemblyPrerequisitesImported)' != 'true'" Project="ThisAssembly.Prerequisites.targets" />
</Project>
5 changes: 2 additions & 3 deletions src/ThisAssembly.Project/ThisAssembly.Project.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>latest</LangVersion>
<IsRoslynComponent>true</IsRoslynComponent>
<CustomAfterMicrosoftCSharpTargets>$(MSBuildThisFileDirectory)..\SponsorLink\SponsorLink.targets</CustomAfterMicrosoftCSharpTargets>
</PropertyGroup>

<PropertyGroup>
Expand Down Expand Up @@ -38,9 +39,7 @@ C#:
</PropertyGroup>

<ItemGroup>
<!--<PackageReference Include="Devlooped.SponsorLink" Version="1.0.0" />-->
<PackageReference Include="NuGetizer" Version="1.2.2" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="all" />

<PackageReference Include="Scriban" Version="5.10.0" Pack="false" IncludeAssets="build" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
Expand Down
2 changes: 1 addition & 1 deletion src/ThisAssembly.Project/ThisAssembly.Project.targets
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<Project>
<Import Project="..\buildTransitive\Devlooped.Sponsors.targets" Condition="Exists('..\buildTransitive\Devlooped.Sponsors.targets')"/>

<ItemGroup>
<!-- Make sure we're always private to the referencing project.
Expand Down Expand Up @@ -28,5 +29,4 @@
</ItemGroup>
</Target>

<Import Condition="'$(ThisAssemblyPrerequisitesImported)' != 'true'" Project="ThisAssembly.Prerequisites.targets" />
</Project>
7 changes: 1 addition & 6 deletions src/ThisAssembly.Resources/ThisAssembly.Resources.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<!-- We cannot use ThisAssembly.Resources as the assembly name, or for whatever
reason, it's never added as an analyzer :/ -->
<AssemblyName>ThisAssembly.Resource</AssemblyName>
<CustomAfterMicrosoftCSharpTargets>$(MSBuildThisFileDirectory)..\SponsorLink\SponsorLink.targets</CustomAfterMicrosoftCSharpTargets>
</PropertyGroup>

<PropertyGroup>
Expand All @@ -19,13 +20,7 @@
</PropertyGroup>

<ItemGroup>
<None Remove="ThisAssembly.Resources.targets" />
</ItemGroup>

<ItemGroup>
<!--<PackageReference Include="Devlooped.SponsorLink" Version="1.0.0" />-->
<PackageReference Include="NuGetizer" Version="1.2.2" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="all" />

<PackageReference Include="Scriban" Version="5.10.0" Pack="false" IncludeAssets="build" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
Expand Down
2 changes: 1 addition & 1 deletion src/ThisAssembly.Resources/ThisAssembly.Resources.targets
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<Project>
<Import Project="..\buildTransitive\Devlooped.Sponsors.targets" Condition="Exists('..\buildTransitive\Devlooped.Sponsors.targets')"/>

<ItemGroup>
<!-- Make sure we're always private to the referencing project.
Expand Down Expand Up @@ -43,5 +44,4 @@
</ItemGroup>
</Target>

<Import Condition="'$(ThisAssemblyPrerequisitesImported)' != 'true'" Project="ThisAssembly.Prerequisites.targets" />
</Project>
Loading