From 791a92f1ca48777a98611a69371995301b7d8d4f Mon Sep 17 00:00:00 2001 From: Mikayla Hutchinson Date: Wed, 5 Oct 2022 03:00:33 -0400 Subject: [PATCH 1/7] Build release branches and tags --- .github/workflows/main.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 73e0c7e..2e72872 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,6 +4,9 @@ on: push: branches: - main + - 'release/v*' + tags: + - 'v*' concurrency: group: ci-main-${{ github.ref }}-1 @@ -14,4 +17,4 @@ jobs: uses: ./.github/workflows/build.yml publish: needs: build - uses: ./.github/workflows/publish.yml \ No newline at end of file + uses: ./.github/workflows/publish.yml From 9a243df9b865b5d5938927eed50a2f7d24139d4f Mon Sep 17 00:00:00 2001 From: Mikayla Hutchinson Date: Wed, 5 Oct 2022 03:33:47 -0400 Subject: [PATCH 2/7] Pass NuGet secret to child workflow --- .github/workflows/main.yml | 2 ++ .github/workflows/publish.yml | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2e72872..8dbaab1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,3 +18,5 @@ jobs: publish: needs: build uses: ./.github/workflows/publish.yml + secrets: + NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 09c47f0..dda4525 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,6 +1,11 @@ name: Publish -on: workflow_call +on: + workflow_call: + secrets: + NUGET_API_KEY: + description: 'NuGet.org API key for the packages to be published' + required: true jobs: publish: @@ -18,4 +23,4 @@ jobs: - name: Publish to NuGet.org if: startsWith(github.ref, 'refs/tags/v') run: | - dotnet nuget push "packages\**\*.nupkg" --api-key ${{ secrets.NUGETAPIKEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate + dotnet nuget push "packages\**\*.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate From 6923091e8434d62494344306537ad89de53ae9fa Mon Sep 17 00:00:00 2001 From: Mikayla Hutchinson Date: Wed, 5 Oct 2022 04:03:31 -0400 Subject: [PATCH 3/7] Remove empty snupkgs as NuGet.org rejects them --- Mono.TextTemplating.Roslyn/Mono.TextTemplating.Roslyn.csproj | 2 -- Mono.TextTemplating/Mono.TextTemplating.csproj | 2 -- TextTransform/TextTransform.csproj | 2 -- 3 files changed, 6 deletions(-) diff --git a/Mono.TextTemplating.Roslyn/Mono.TextTemplating.Roslyn.csproj b/Mono.TextTemplating.Roslyn/Mono.TextTemplating.Roslyn.csproj index b3bd08c..764b204 100644 --- a/Mono.TextTemplating.Roslyn/Mono.TextTemplating.Roslyn.csproj +++ b/Mono.TextTemplating.Roslyn/Mono.TextTemplating.Roslyn.csproj @@ -9,8 +9,6 @@ In-process Roslyn compiler for the Mono.TextTemplating T4 templating engine true true - true - snupkg readme.md diff --git a/Mono.TextTemplating/Mono.TextTemplating.csproj b/Mono.TextTemplating/Mono.TextTemplating.csproj index b9e7ad0..e2af3d8 100644 --- a/Mono.TextTemplating/Mono.TextTemplating.csproj +++ b/Mono.TextTemplating/Mono.TextTemplating.csproj @@ -13,8 +13,6 @@ $(DefineConstants);FEATURE_APPDOMAINS $(DefineConstants);FEATURE_ASSEMBLY_LOAD_CONTEXT true - true - snupkg readme.md diff --git a/TextTransform/TextTransform.csproj b/TextTransform/TextTransform.csproj index 5974756..4085285 100644 --- a/TextTransform/TextTransform.csproj +++ b/TextTransform/TextTransform.csproj @@ -11,8 +11,6 @@ True Command-line T4 text transform tool. true - true - snupkg From b8ced9fdf70b75fabc6830220bba63e45cf4059c Mon Sep 17 00:00:00 2001 From: Mikayla Hutchinson Date: Fri, 28 Oct 2022 17:06:41 -0400 Subject: [PATCH 4/7] Run PRs against release branches --- .github/workflows/pull_request.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index c2b7a7b..b3242d2 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -4,6 +4,7 @@ on: pull_request: branches: - main + - 'release/v*' concurrency: group: ci-pr-${{ github.ref }}-1 From 48052327340fc6e4322a75e505d6968eacfc583d Mon Sep 17 00:00:00 2001 From: Mikayla Hutchinson Date: Fri, 28 Oct 2022 16:34:55 -0400 Subject: [PATCH 5/7] Fix output extension directive and add test Fixes #142 --- Mono.TextTemplating.Tests/ProcessingTests.cs | 16 ++++++++++++++++ .../Mono.TextTemplating/TemplateGenerator.cs | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Mono.TextTemplating.Tests/ProcessingTests.cs b/Mono.TextTemplating.Tests/ProcessingTests.cs index 1043f3e..78ac889 100644 --- a/Mono.TextTemplating.Tests/ProcessingTests.cs +++ b/Mono.TextTemplating.Tests/ProcessingTests.cs @@ -117,6 +117,22 @@ public async Task SetLangVersionViaAdditionalArgsInProcess () } #endif + [Fact] + public async Task SetOutputExtension () + { + string inputContent = "<#@ output extension=\".cfg\" #>"; + string inputFile = "hello.tt"; + string outputName = "hello.txt"; + + // this reproduces the calls made by dotnet-t4 + var gen = new TemplateGenerator (); + var pt = gen.ParseTemplate (inputFile, inputContent); + TemplateSettings settings = TemplatingEngine.GetSettings (gen, pt); + (outputName, _) = await gen.ProcessTemplateAsync (pt, inputFile, inputContent, outputName, settings); + + Assert.Equal ("hello.cfg", outputName); + } + [Fact] public async Task ImportReferencesTest () { diff --git a/Mono.TextTemplating/Mono.TextTemplating/TemplateGenerator.cs b/Mono.TextTemplating/Mono.TextTemplating/TemplateGenerator.cs index b92273b..92a8666 100644 --- a/Mono.TextTemplating/Mono.TextTemplating/TemplateGenerator.cs +++ b/Mono.TextTemplating/Mono.TextTemplating/TemplateGenerator.cs @@ -268,7 +268,7 @@ public string PreprocessTemplate ( var outputContent = await Engine.ProcessTemplateAsync (pt, inputContent, settings, this, token).ConfigureAwait (false); - return (outputFileName, outputContent); + return (OutputFile, outputContent); } #region Virtual members From de2b3b604438bb3ef48afffd47aaced8a8096ec0 Mon Sep 17 00:00:00 2001 From: Mikayla Hutchinson Date: Fri, 28 Oct 2022 17:13:06 -0400 Subject: [PATCH 6/7] Fix loading System.Text.Json in ALC Fixes #143 --- .../AssemblyLoadContextTests.cs | 15 +++++++++++++++ .../TemplateAssemblyLoadContext.cs | 18 +++++++++++++++--- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/Mono.TextTemplating.Tests/AssemblyLoadContextTests.cs b/Mono.TextTemplating.Tests/AssemblyLoadContextTests.cs index 9ca2997..4b8bb5b 100644 --- a/Mono.TextTemplating.Tests/AssemblyLoadContextTests.cs +++ b/Mono.TextTemplating.Tests/AssemblyLoadContextTests.cs @@ -31,6 +31,21 @@ protected override void VerifyFinalState ((SnapshotSet assembliesInDefau state.allContexts.AssertUnchanged (); } + + /// Issue #143: System.Text.Json is a framework assembly on .NET Core 3.0 and does not need to be specified by absolute path + [Fact] + public async Task LoadSystemTextJson () + { + string template = "<#@ assembly name=\"System.Text.Json\" #><#=System.Text.Json.JsonValueKind.Array.ToString()#>"; + + var gen = new TemplateGenerator (); + (_, string content, _) = await gen.ProcessTemplateAsync (null, template, null); + + CompilerError firstError = gen.Errors.OfType ().FirstOrDefault (); + Assert.Null (firstError); + + Assert.Equal ("Array", content); + } } #endif \ No newline at end of file diff --git a/Mono.TextTemplating/Mono.TextTemplating/TemplateAssemblyLoadContext.cs b/Mono.TextTemplating/Mono.TextTemplating/TemplateAssemblyLoadContext.cs index 59bb59b..7453e0c 100644 --- a/Mono.TextTemplating/Mono.TextTemplating/TemplateAssemblyLoadContext.cs +++ b/Mono.TextTemplating/Mono.TextTemplating/TemplateAssemblyLoadContext.cs @@ -3,6 +3,7 @@ #if FEATURE_ASSEMBLY_LOAD_CONTEXT +using System; using System.CodeDom.Compiler; using System.IO; using System.Reflection; @@ -52,9 +53,20 @@ protected override Assembly Load (AssemblyName assemblyName) return hostAssembly; } - foreach (var asmFile in templateAssemblyFiles) { - if (assemblyName.Name == Path.GetFileNameWithoutExtension (asmFile)) { - return LoadFromAssemblyPath (asmFile); + for (int i = 0; i < templateAssemblyFiles.Length; i++) { + var asmFile = templateAssemblyFiles[i]; + if (asmFile is null) { + continue; + } + if (MemoryExtensions.Equals (assemblyName.Name, Path.GetFileNameWithoutExtension (asmFile.AsSpan()), StringComparison.OrdinalIgnoreCase)) { + // if the file doesn't exist, fall through to host.ResolveAssemblyReference + if (File.Exists (asmFile)) { + return LoadFromAssemblyPath (asmFile); + } else { + // null out the missing file so we don't check it exists again + templateAssemblyFiles[i] = null; + break; + } } } From 932110915c6febbd0219334b1306aa962eb4ef2f Mon Sep 17 00:00:00 2001 From: Mikayla Hutchinson Date: Fri, 28 Oct 2022 17:39:12 -0400 Subject: [PATCH 7/7] Set version to 2.3.1 --- version.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.json b/version.json index 0fba6df..623e869 100644 --- a/version.json +++ b/version.json @@ -1,6 +1,6 @@ { "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", - "version": "2.4.0-preview.{height}", + "version": "2.3.1", "publicReleaseRefSpec": [ "^refs/tags/v\\d+\\.\\d+$", "^refs/tags/v\\d+\\.\\d+\\.\\d+$" @@ -14,4 +14,4 @@ "branchName": "release/v{version}", "firstUnstableTag": "preview" } -} \ No newline at end of file +}