From 28160c8a52908387e3ba3e51901766ab0ddaafd8 Mon Sep 17 00:00:00 2001 From: Dustin Masters Date: Sun, 8 Mar 2020 22:05:29 -0700 Subject: [PATCH 1/4] Webpack template: Spawn webpack dev server in background --- .../reactnet-webpack/Program.cs | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/React.Template/reactnet-webpack/Program.cs b/src/React.Template/reactnet-webpack/Program.cs index 0929370a8..d6f6ba5f7 100644 --- a/src/React.Template/reactnet-webpack/Program.cs +++ b/src/React.Template/reactnet-webpack/Program.cs @@ -1,5 +1,11 @@ +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.DependencyInjection; +using System; namespace React.Sample.Webpack.CoreMvc { @@ -13,6 +19,32 @@ public static void Main(string[] args) public static IWebHost BuildWebHost(string[] args) => WebHost.CreateDefaultBuilder(args) .UseStartup() + .ConfigureServices((hostContext, service) => + { + service.AddHostedService(); + }) .Build(); + + private class WebpackDevServer : BackgroundService + { + protected override Task ExecuteAsync(CancellationToken token) + { + if (Environment.OSVersion.Platform == PlatformID.Win32NT) + { + var devServer = Process.Start(new ProcessStartInfo + { + Arguments = "/c npm i && npm run build -- --watch", + RedirectStandardError = false, + RedirectStandardInput = false, + RedirectStandardOutput = false, + FileName = "cmd.exe" + }); + + token.Register(() => devServer?.Kill(true)); + } + + return Task.Delay(Timeout.Infinite, token); + } + } } } From fc2514087168f4e8f3a83d5572b46e0205f8848a Mon Sep 17 00:00:00 2001 From: Dustin Masters Date: Mon, 15 Jun 2020 14:52:34 -0700 Subject: [PATCH 2/4] Create dotnet-core-desktop.yml --- .github/workflows/dotnet-core-desktop.yml | 49 +++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/dotnet-core-desktop.yml diff --git a/.github/workflows/dotnet-core-desktop.yml b/.github/workflows/dotnet-core-desktop.yml new file mode 100644 index 000000000..592efc514 --- /dev/null +++ b/.github/workflows/dotnet-core-desktop.yml @@ -0,0 +1,49 @@ +name: .NET Core Desktop + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + + build: + + strategy: + matrix: + configuration: [Debug, Release] + + runs-on: windows-latest # For a list of available runner types, refer to + # https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Install .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.1.101 + + - name: Use Node.js 12 + uses: actions/setup-node@v1 + with: + node-version: 12 + + - name: Setup MSBuild.exe + uses: microsoft/setup-msbuild@2008f912f56e61277eefaac6d1888b750582aa16 + + - name: Build + run: msbuild build.proj /p:PackageOutputDir="nuget-output" /p:Configuration=${{ matrix.configuration }} + env: + Configuration: ${{ matrix.configuration }} + + - name: Nuget pack + - name: Upload build artifacts + uses: actions/upload-artifact@v1 + with: + name: Nuget Package + path: nuget-output From 99dccf00cbfc03e423e090b630a06a0ed1f7ec72 Mon Sep 17 00:00:00 2001 From: Dustin Masters Date: Mon, 15 Jun 2020 14:53:37 -0700 Subject: [PATCH 3/4] Update dotnet-core-desktop.yml --- .github/workflows/dotnet-core-desktop.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/dotnet-core-desktop.yml b/.github/workflows/dotnet-core-desktop.yml index 592efc514..a4f2f2a6e 100644 --- a/.github/workflows/dotnet-core-desktop.yml +++ b/.github/workflows/dotnet-core-desktop.yml @@ -41,7 +41,6 @@ jobs: env: Configuration: ${{ matrix.configuration }} - - name: Nuget pack - name: Upload build artifacts uses: actions/upload-artifact@v1 with: From d0265e1703d792c44756526f5125bc47ab23992b Mon Sep 17 00:00:00 2001 From: Dustin Masters Date: Mon, 15 Jun 2020 15:08:24 -0700 Subject: [PATCH 4/4] Update dotnet-core-desktop.yml --- .github/workflows/dotnet-core-desktop.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dotnet-core-desktop.yml b/.github/workflows/dotnet-core-desktop.yml index a4f2f2a6e..9a026c0d8 100644 --- a/.github/workflows/dotnet-core-desktop.yml +++ b/.github/workflows/dotnet-core-desktop.yml @@ -37,7 +37,7 @@ jobs: uses: microsoft/setup-msbuild@2008f912f56e61277eefaac6d1888b750582aa16 - name: Build - run: msbuild build.proj /p:PackageOutputDir="nuget-output" /p:Configuration=${{ matrix.configuration }} + run: msbuild build.proj /p:PackageOutputDir="${{ env.GITHUB_WORKSPACE }}/nuget-output" /p:Configuration=${{ matrix.configuration }} env: Configuration: ${{ matrix.configuration }} @@ -45,4 +45,4 @@ jobs: uses: actions/upload-artifact@v1 with: name: Nuget Package - path: nuget-output + path: "${{ env.GITHUB_WORKSPACE }}/nuget-output"