-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Fixes unhandled exception with GetRootedPath #1251 * Update build version
- Loading branch information
1 parent
cb799e1
commit 7906d68
Showing
14 changed files
with
135 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<Project> | ||
<ItemGroup> | ||
<CompilerVisibleProperty Include="PSRule_Version" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using Microsoft.CodeAnalysis; | ||
|
||
namespace PSRule.BuildTask.Generators | ||
{ | ||
/// <summary> | ||
/// Generator contants for PSRule engine version. | ||
/// </summary> | ||
[Generator] | ||
public sealed class EngineVersionGenerator : ISourceGenerator | ||
{ | ||
// Detailed from Roslyn SDK: https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/source-generators-overview | ||
|
||
/// <inheritdoc/> | ||
public void Execute(GeneratorExecutionContext context) | ||
{ | ||
var result = GetPartialContent(context); | ||
context.AddSource("EngineVersion.g.cs", result); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public void Initialize(GeneratorInitializationContext context) | ||
{ | ||
// Not required. | ||
} | ||
|
||
private static string GetPartialContent(GeneratorExecutionContext context) | ||
{ | ||
if (!context.AnalyzerConfigOptions.GlobalOptions.TryGetValue("build_property.PSRule_Version", out var productVersion)) | ||
productVersion = "0.0.1"; | ||
|
||
// Build up the source code | ||
return $@"// <auto-generated/> | ||
using System; | ||
namespace PSRule | ||
{{ | ||
internal static partial class Engine | ||
{{ | ||
private const string _Version = ""{productVersion}""; | ||
}} | ||
}} | ||
"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<Import Project="..\PSRule.Common.props" /> | ||
<PropertyGroup> | ||
<AssemblyTitle>PSRule.BuildTask</AssemblyTitle> | ||
<EnableNuget>false</EnableNuget> | ||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.2.0" /> | ||
</ItemGroup> | ||
|
||
<!--<ItemGroup> | ||
<None Include="Generator.props" Pack="true" PackagePath="build" Visible="false" /> | ||
</ItemGroup>--> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using System.IO; | ||
using PSRule.Configuration; | ||
|
||
namespace PSRule | ||
{ | ||
internal static partial class Engine | ||
{ | ||
internal static string GetLocalPath() | ||
{ | ||
return PSRuleOption.GetRootedBasePath(Path.GetDirectoryName(AppContext.BaseDirectory)); | ||
} | ||
|
||
internal static string GetVersion() | ||
{ | ||
return _Version; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters