From d1d656d5b895690ad5b9c5aaeaa21c02d88f7285 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 15 Mar 2017 09:29:05 -0700 Subject: [PATCH] Add samples and update READMEs (#275) --- .../LaunchAnyCommand/LaunchAnyCommand.csproj | 15 ++++++++++ .../dotnet-watch/LaunchAnyCommand/README.md | 18 ++++++++++++ .../LaunchAnyCommand/package.json | 8 ++++++ .../LaunchAnyCommand/say-hello.js | 1 + samples/dotnet-watch/README.md | 5 ++++ .../WatchJavascriptFiles/Program.cs | 28 +++++++++++++++++++ .../WatchJavascriptFiles/README.md | 17 +++++++++++ .../WatchJavascriptFiles.csproj | 17 +++++++++++ .../WatchJavascriptFiles/wwwroot/app.js | 1 + .../WatchMultipleProjects/README.md | 19 +++++++++++++ .../WatchMultipleProjects/Test/Test.csproj | 13 +++++++++ .../WatchMultipleProjects/Test/UnitTest1.cs | 17 +++++++++++ .../WatchMultipleProjects/Web/Program.cs | 28 +++++++++++++++++++ .../WatchMultipleProjects/Web/Web.csproj | 15 ++++++++++ .../WatchMultipleProjects/watch.proj | 19 +++++++++++++ src/Microsoft.DotNet.Watcher.Tools/README.md | 6 ++-- .../README.md | 4 +-- .../README.md | 4 +-- 18 files changed, 228 insertions(+), 7 deletions(-) create mode 100644 samples/dotnet-watch/LaunchAnyCommand/LaunchAnyCommand.csproj create mode 100644 samples/dotnet-watch/LaunchAnyCommand/README.md create mode 100644 samples/dotnet-watch/LaunchAnyCommand/package.json create mode 100644 samples/dotnet-watch/LaunchAnyCommand/say-hello.js create mode 100644 samples/dotnet-watch/README.md create mode 100755 samples/dotnet-watch/WatchJavascriptFiles/Program.cs create mode 100644 samples/dotnet-watch/WatchJavascriptFiles/README.md create mode 100755 samples/dotnet-watch/WatchJavascriptFiles/WatchJavascriptFiles.csproj create mode 100644 samples/dotnet-watch/WatchJavascriptFiles/wwwroot/app.js create mode 100644 samples/dotnet-watch/WatchMultipleProjects/README.md create mode 100755 samples/dotnet-watch/WatchMultipleProjects/Test/Test.csproj create mode 100755 samples/dotnet-watch/WatchMultipleProjects/Test/UnitTest1.cs create mode 100755 samples/dotnet-watch/WatchMultipleProjects/Web/Program.cs create mode 100755 samples/dotnet-watch/WatchMultipleProjects/Web/Web.csproj create mode 100644 samples/dotnet-watch/WatchMultipleProjects/watch.proj diff --git a/samples/dotnet-watch/LaunchAnyCommand/LaunchAnyCommand.csproj b/samples/dotnet-watch/LaunchAnyCommand/LaunchAnyCommand.csproj new file mode 100644 index 0000000000..80e25acb9c --- /dev/null +++ b/samples/dotnet-watch/LaunchAnyCommand/LaunchAnyCommand.csproj @@ -0,0 +1,15 @@ + + + netcoreapp1.1 + + + + + + + + + + + + diff --git a/samples/dotnet-watch/LaunchAnyCommand/README.md b/samples/dotnet-watch/LaunchAnyCommand/README.md new file mode 100644 index 0000000000..698d69225d --- /dev/null +++ b/samples/dotnet-watch/LaunchAnyCommand/README.md @@ -0,0 +1,18 @@ +Launch any command with dotnet-watch +==================================== + +## Prerequisites + +1. Install .NET Core command line. +2. Install NodeJS. + +## Usage + +Open a terminal to the directory containing this project. + +``` +dotnet restore +dotnet watch msbuild /t:RunMyNpmCommand +``` + +Changing the .csproj file, or the say-hello.js file will cause dotnet-watch to re-run the 'RunMyNpmCommand' target in MyApp.csproj. diff --git a/samples/dotnet-watch/LaunchAnyCommand/package.json b/samples/dotnet-watch/LaunchAnyCommand/package.json new file mode 100644 index 0000000000..61e25fb082 --- /dev/null +++ b/samples/dotnet-watch/LaunchAnyCommand/package.json @@ -0,0 +1,8 @@ +{ + "name": "any-command", + "version": "0.0.0", + "private": true, + "scripts": { + "custom": "node say-hello.js" + } +} diff --git a/samples/dotnet-watch/LaunchAnyCommand/say-hello.js b/samples/dotnet-watch/LaunchAnyCommand/say-hello.js new file mode 100644 index 0000000000..c35728f5a1 --- /dev/null +++ b/samples/dotnet-watch/LaunchAnyCommand/say-hello.js @@ -0,0 +1 @@ +console.log("Hello from Javascript"); diff --git a/samples/dotnet-watch/README.md b/samples/dotnet-watch/README.md new file mode 100644 index 0000000000..467a552f7e --- /dev/null +++ b/samples/dotnet-watch/README.md @@ -0,0 +1,5 @@ +dotnet-watch samples +==================== + +The samples in this folder show some ways to customize dotnet-watch. For full details on +available settings and configuration, see the [README for the Microsoft.DotNet.Watcher.Tools](../../src/Microsoft.DotNet.Watcher.Tools/README.md) project. diff --git a/samples/dotnet-watch/WatchJavascriptFiles/Program.cs b/samples/dotnet-watch/WatchJavascriptFiles/Program.cs new file mode 100755 index 0000000000..f71a9e073d --- /dev/null +++ b/samples/dotnet-watch/WatchJavascriptFiles/Program.cs @@ -0,0 +1,28 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.IO; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; + +namespace WatchJavascriptFiles +{ + public class Program + { + public static void Main(string[] args) + { + var host = new WebHostBuilder() + .UseKestrel() + .UseContentRoot(Directory.GetCurrentDirectory()) + .Configure(app => + app.Run(async (context) => + { + await context.Response.WriteAsync("Hello World!"); + })) + .Build(); + + host.Run(); + } + } +} diff --git a/samples/dotnet-watch/WatchJavascriptFiles/README.md b/samples/dotnet-watch/WatchJavascriptFiles/README.md new file mode 100644 index 0000000000..dc98940cd7 --- /dev/null +++ b/samples/dotnet-watch/WatchJavascriptFiles/README.md @@ -0,0 +1,17 @@ +Watch JavaScript files with dotnet-watch +======================================== + +## Prerequisites + +Install .NET Core command line. + +## Usage + +Open a terminal to the directory containing this project. + +``` +dotnet restore +dotnet watch run +``` + +Changing the .csproj file, or \*.js file in wwwroot, or any \*.cs file will cause dotnet-watch to restart the website. diff --git a/samples/dotnet-watch/WatchJavascriptFiles/WatchJavascriptFiles.csproj b/samples/dotnet-watch/WatchJavascriptFiles/WatchJavascriptFiles.csproj new file mode 100755 index 0000000000..4ff79540da --- /dev/null +++ b/samples/dotnet-watch/WatchJavascriptFiles/WatchJavascriptFiles.csproj @@ -0,0 +1,17 @@ + + + + netcoreapp1.1 + + + + + + + + + + + + + diff --git a/samples/dotnet-watch/WatchJavascriptFiles/wwwroot/app.js b/samples/dotnet-watch/WatchJavascriptFiles/wwwroot/app.js new file mode 100644 index 0000000000..a94cbdc370 --- /dev/null +++ b/samples/dotnet-watch/WatchJavascriptFiles/wwwroot/app.js @@ -0,0 +1 @@ +document.title = "My awesome website"; diff --git a/samples/dotnet-watch/WatchMultipleProjects/README.md b/samples/dotnet-watch/WatchMultipleProjects/README.md new file mode 100644 index 0000000000..2c01233d36 --- /dev/null +++ b/samples/dotnet-watch/WatchMultipleProjects/README.md @@ -0,0 +1,19 @@ +Watch multiple projects with dotnet-watch +========================================= + +## Prerequisites + +Install .NET Core command line. + +## Usage + +Open a terminal to the directory containing this project. + +``` +dotnet restore watch.proj +dotnet watch msbuild watch.proj /t:TestAndRun +``` + +The "TestAndRun" target in watch.proj will execute "dotnet test" on Test.csproj and then launch the website by calling "dotnet run" on Web.csproj. + +Changing any \*.cs file in Test/ or Web/, any \*.csproj file, or watch.proj, will cause dotnet-watch to relaunch the "TestAndRun" target from watch.proj. diff --git a/samples/dotnet-watch/WatchMultipleProjects/Test/Test.csproj b/samples/dotnet-watch/WatchMultipleProjects/Test/Test.csproj new file mode 100755 index 0000000000..7c8da8f68a --- /dev/null +++ b/samples/dotnet-watch/WatchMultipleProjects/Test/Test.csproj @@ -0,0 +1,13 @@ + + + + netcoreapp1.1 + + + + + + + + + diff --git a/samples/dotnet-watch/WatchMultipleProjects/Test/UnitTest1.cs b/samples/dotnet-watch/WatchMultipleProjects/Test/UnitTest1.cs new file mode 100755 index 0000000000..0da9a7f234 --- /dev/null +++ b/samples/dotnet-watch/WatchMultipleProjects/Test/UnitTest1.cs @@ -0,0 +1,17 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Xunit; + +namespace Test +{ + public class UnitTest1 + { + [Fact] + public void Test1() + { + Assert.True(true); + } + } +} diff --git a/samples/dotnet-watch/WatchMultipleProjects/Web/Program.cs b/samples/dotnet-watch/WatchMultipleProjects/Web/Program.cs new file mode 100755 index 0000000000..6a02b1f332 --- /dev/null +++ b/samples/dotnet-watch/WatchMultipleProjects/Web/Program.cs @@ -0,0 +1,28 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.IO; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; + +namespace Web +{ + public class Program + { + public static void Main(string[] args) + { + var host = new WebHostBuilder() + .UseKestrel() + .UseContentRoot(Directory.GetCurrentDirectory()) + .Configure(app => + app.Run(async (context) => + { + await context.Response.WriteAsync("Hello World!"); + })) + .Build(); + + host.Run(); + } + } +} diff --git a/samples/dotnet-watch/WatchMultipleProjects/Web/Web.csproj b/samples/dotnet-watch/WatchMultipleProjects/Web/Web.csproj new file mode 100755 index 0000000000..4b6806ff93 --- /dev/null +++ b/samples/dotnet-watch/WatchMultipleProjects/Web/Web.csproj @@ -0,0 +1,15 @@ + + + + netcoreapp1.1 + + + + + + + + + + + diff --git a/samples/dotnet-watch/WatchMultipleProjects/watch.proj b/samples/dotnet-watch/WatchMultipleProjects/watch.proj new file mode 100644 index 0000000000..fd05a8a4e9 --- /dev/null +++ b/samples/dotnet-watch/WatchMultipleProjects/watch.proj @@ -0,0 +1,19 @@ + + + netcoreapp1.1 + + + + + + + + + + + + + + + + diff --git a/src/Microsoft.DotNet.Watcher.Tools/README.md b/src/Microsoft.DotNet.Watcher.Tools/README.md index 894ef42864..32ecfdcc2a 100644 --- a/src/Microsoft.DotNet.Watcher.Tools/README.md +++ b/src/Microsoft.DotNet.Watcher.Tools/README.md @@ -8,7 +8,7 @@ Install `Microsoft.DotNet.Watcher.Tools` as a `DotNetCliToolReference` to your p ```xml - + ``` @@ -65,9 +65,9 @@ Example: ```xml - + - + ``` diff --git a/src/Microsoft.Extensions.Caching.SqlConfig.Tools/README.md b/src/Microsoft.Extensions.Caching.SqlConfig.Tools/README.md index 0d989a980d..ec0c35973a 100644 --- a/src/Microsoft.Extensions.Caching.SqlConfig.Tools/README.md +++ b/src/Microsoft.Extensions.Caching.SqlConfig.Tools/README.md @@ -9,10 +9,10 @@ Install `Microsoft.Extensions.Caching.SqlConfig.Tools` as a `DotNetCliToolRefere ```xml - + ``` ### How To Use -Run `dotnet sql-cache --help` for more information about usage. \ No newline at end of file +Run `dotnet sql-cache --help` for more information about usage. diff --git a/src/Microsoft.Extensions.SecretManager.Tools/README.md b/src/Microsoft.Extensions.SecretManager.Tools/README.md index b930f9dd71..a933ba8c30 100644 --- a/src/Microsoft.Extensions.SecretManager.Tools/README.md +++ b/src/Microsoft.Extensions.SecretManager.Tools/README.md @@ -9,10 +9,10 @@ Install `Microsoft.Extensions.SecretManager.Tools` as a `DotNetCliToolReference` ```xml - + ``` ### How To Use -Run `dotnet user-secrets --help` for more information about usage. \ No newline at end of file +Run `dotnet user-secrets --help` for more information about usage.