Skip to content

Commit

Permalink
Add prerequisite checks to avoid confusing users
Browse files Browse the repository at this point in the history
Explicit build targets now check for the two requirements for
ThisAssembly: MSBuild 16.8+ or .NET SDK 5.0+ and C#.
  • Loading branch information
kzu committed Oct 3, 2020
1 parent d7566fe commit 4834a64
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 1 deletion.
6 changes: 6 additions & 0 deletions ThisAssembly.sln
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{
.github\workflows\release.yml = .github\workflows\release.yml
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ThisAssembly.Prerequisites", "src\ThisAssembly.Prerequisites\ThisAssembly.Prerequisites.csproj", "{568E5150-84AD-4619-BEA3-AA5EDF084ABC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -59,6 +61,10 @@ Global
{3E7158B5-BFEF-4416-8226-9096C7C98268}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3E7158B5-BFEF-4416-8226-9096C7C98268}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3E7158B5-BFEF-4416-8226-9096C7C98268}.Release|Any CPU.Build.0 = Release|Any CPU
{568E5150-84AD-4619-BEA3-AA5EDF084ABC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{568E5150-84AD-4619-BEA3-AA5EDF084ABC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{568E5150-84AD-4619-BEA3-AA5EDF084ABC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{568E5150-84AD-4619-BEA3-AA5EDF084ABC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ on the `ThisAssembly.Info` class.

<ItemGroup>
<ProjectReference Include="../ThisAssembly.DesignTimeFix/ThisAssembly.DesignTimeFix.csproj" />
<ProjectReference Include="..\ThisAssembly.Prerequisites\ThisAssembly.Prerequisites.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions src/ThisAssembly.Metadata/ThisAssembly.Metadata.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ F#:

<ItemGroup>
<ProjectReference Include="../ThisAssembly.DesignTimeFix/ThisAssembly.DesignTimeFix.csproj" />
<ProjectReference Include="..\ThisAssembly.Prerequisites\ThisAssembly.Prerequisites.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
26 changes: 26 additions & 0 deletions src/ThisAssembly.Prerequisites/ThisAssembly.Prerequisites.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<PackBuildOutput>false</PackBuildOutput>
</PropertyGroup>

<PropertyGroup>
<PackageId>ThisAssembly.Prerequisites</PackageId>
<Description>Ensures that referencing project satisfies the prerequisites for ThisAssembly, namely:

* MSBuild 16.8+: contains the Roslyn support for source generators
* C# language: it's the only language supported by Roslyn source generators at the moment.
</Description>
</PropertyGroup>

<ItemGroup>
<Compile Remove="@(Compile)" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="NuGetizer" Version="0.4.1" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="all" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Project>

<PropertyGroup>
<LangVersion>Preview</LangVersion>
</PropertyGroup>

</Project>
10 changes: 10 additions & 0 deletions src/ThisAssembly.Prerequisites/ThisAssembly.Prerequisites.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project>

<Target Name="EnsureSourceGenerators" BeforeTargets="BeforeCompile;CoreCompile">
<Error Text="ThisAssembly requires MSBuild 16.8+ or .NET SDK 5.0+."
Condition="$([MSBuild]::VersionLessThan($(MSBuildVersion), '16.8'))" />
<Error Text="ThisAssembly uses Roslyn source generators, which are only supported in C# at the moment."
Condition="'$(Language)' != 'C#'" />
</Target>

</Project>
1 change: 1 addition & 0 deletions src/ThisAssembly.Project/ThisAssembly.Project.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ F#:

<ItemGroup>
<ProjectReference Include="../ThisAssembly.DesignTimeFix/ThisAssembly.DesignTimeFix.csproj" />
<ProjectReference Include="..\ThisAssembly.Prerequisites\ThisAssembly.Prerequisites.csproj" />
</ItemGroup>

</Project>
3 changes: 2 additions & 1 deletion src/ThisAssembly.Strings/ThisAssembly.Strings.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ such as "Hello {name}".
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="all" />
<PackageReference Include="Scriban" Version="2.1.4" PrivateAssets="all" />

<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.8.0-3.final" Pack="false"/>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.8.0-3.final" Pack="false" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="../ThisAssembly.DesignTimeFix/ThisAssembly.DesignTimeFix.csproj" />
<ProjectReference Include="..\ThisAssembly.Prerequisites\ThisAssembly.Prerequisites.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 4834a64

Please sign in to comment.