Add samples and update READMEs (#275)
This commit is contained in:
Родитель
8c32731282
Коммит
d1d656d5b8
|
@ -0,0 +1,15 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp1.1</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="1.0.0" />
|
||||
|
||||
<Watch Include="say-hello.js" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="RunMyNpmCommand">
|
||||
<Exec Command="npm run custom" />
|
||||
</Target>
|
||||
</Project>
|
|
@ -0,0 +1,18 @@
|
|||
Launch any command with dotnet-watch
|
||||
====================================
|
||||
|
||||
## Prerequisites
|
||||
|
||||
1. Install .NET Core command line. <https://dot.net/core>
|
||||
2. Install NodeJS. <https://nodejs.org>
|
||||
|
||||
## 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.
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "any-command",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"custom": "node say-hello.js"
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
console.log("Hello from Javascript");
|
|
@ -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.
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
Watch JavaScript files with dotnet-watch
|
||||
========================================
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Install .NET Core command line. <https://dot.net/core>
|
||||
|
||||
## 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.
|
|
@ -0,0 +1,17 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp1.1</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="wwwroot\" />
|
||||
<Watch Include="wwwroot\**\*.js" Exclude="wwwroot\node_modules\**\*.js" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
|
||||
<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="1.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -0,0 +1 @@
|
|||
document.title = "My awesome website";
|
|
@ -0,0 +1,19 @@
|
|||
Watch multiple projects with dotnet-watch
|
||||
=========================================
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Install .NET Core command line. <https://dot.net/core>
|
||||
|
||||
## 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.
|
|
@ -0,0 +1,13 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp1.1</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
|
||||
<PackageReference Include="xunit" Version="2.2.0" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp1.1</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="wwwroot\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -0,0 +1,19 @@
|
|||
<Project>
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp1.1</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="1.0.0" />
|
||||
|
||||
<ProjectReference Include="Web\Web.csproj" />
|
||||
<ProjectReference Include="Test\Test.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="TestAndRun">
|
||||
<Exec Command="dotnet test" WorkingDirectory="Test/" />
|
||||
<Exec Command="dotnet run" WorkingDirectory="Web/" />
|
||||
</Target>
|
||||
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets"/>
|
||||
</Project>
|
|
@ -8,7 +8,7 @@ Install `Microsoft.DotNet.Watcher.Tools` as a `DotNetCliToolReference` to your p
|
|||
|
||||
```xml
|
||||
<ItemGroup>
|
||||
<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="1.0.0-msbuild3-final" />
|
||||
<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="1.0.0" />
|
||||
</ItemGroup>
|
||||
```
|
||||
|
||||
|
@ -65,9 +65,9 @@ Example:
|
|||
```xml
|
||||
<ItemGroup>
|
||||
<!-- exclude Generated.cs from dotnet-watch -->
|
||||
<Compile Include="Generated.cs" Watch="false" />
|
||||
<Compile Update="Generated.cs" Watch="false" />
|
||||
<!-- exclude Strings.resx from dotnet-watch -->
|
||||
<EmbeddedResource Include="Strings.resx" Watch="false" />
|
||||
<EmbeddedResource Update="Strings.resx" Watch="false" />
|
||||
</ItemGroup>
|
||||
```
|
||||
|
||||
|
|
|
@ -9,10 +9,10 @@ Install `Microsoft.Extensions.Caching.SqlConfig.Tools` as a `DotNetCliToolRefere
|
|||
|
||||
```xml
|
||||
<ItemGroup>
|
||||
<DotNetCliToolReference Include="Microsoft.Extensions.Caching.SqlConfig.Tools" Version="1.0.0-msbuild2-final" />
|
||||
<DotNetCliToolReference Include="Microsoft.Extensions.Caching.SqlConfig.Tools" Version="1.0.0" />
|
||||
</ItemGroup>
|
||||
```
|
||||
|
||||
### How To Use
|
||||
|
||||
Run `dotnet sql-cache --help` for more information about usage.
|
||||
Run `dotnet sql-cache --help` for more information about usage.
|
||||
|
|
|
@ -9,10 +9,10 @@ Install `Microsoft.Extensions.SecretManager.Tools` as a `DotNetCliToolReference`
|
|||
|
||||
```xml
|
||||
<ItemGroup>
|
||||
<DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="1.0.0-msbuild2-update1" />
|
||||
<DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="1.0.0" />
|
||||
</ItemGroup>
|
||||
```
|
||||
|
||||
### How To Use
|
||||
|
||||
Run `dotnet user-secrets --help` for more information about usage.
|
||||
Run `dotnet user-secrets --help` for more information about usage.
|
||||
|
|
Загрузка…
Ссылка в новой задаче