diff --git a/.github/workflows/dotnet-core-desktop.yml b/.github/workflows/dotnet-core-desktop.yml new file mode 100644 index 000000000..9a026c0d8 --- /dev/null +++ b/.github/workflows/dotnet-core-desktop.yml @@ -0,0 +1,48 @@ +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="${{ env.GITHUB_WORKSPACE }}/nuget-output" /p:Configuration=${{ matrix.configuration }} + env: + Configuration: ${{ matrix.configuration }} + + - name: Upload build artifacts + uses: actions/upload-artifact@v1 + with: + name: Nuget Package + path: "${{ env.GITHUB_WORKSPACE }}/nuget-output" 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); + } + } } }