From f2778165567614face7c9d3bf8af22c8459066c7 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 7 Dec 2016 09:30:18 -0800 Subject: [PATCH] Update packaging for tools Move targets files in to 'toolassets'. The 'tools' folder has conventions in NuGet that we don't want applied to these packages. Downgrade to Microsoft.NETCore.App 1.0.0 Add 'prefercliruntime' package. --- .../Internal/MsBuildFileSetFactory.cs | 5 ++- .../Microsoft.DotNet.Watcher.Tools.nuspec | 9 +++-- .../prefercliruntime | 0 .../project.json | 17 ++------- .../DotNetWatchCommon.targets | 0 .../DotNetWatchInner.targets | 0 .../DotNetWatchOuter.targets | 0 ....Extensions.Caching.SqlConfig.Tools.nuspec | 1 + .../prefercliruntime | 0 .../project.json | 16 ++------ .../Internal/ProjectIdResolver.cs | 38 +++++-------------- ...soft.Extensions.SecretManager.Tools.nuspec | 3 +- .../prefercliruntime | 0 .../project.json | 29 ++------------ .../FindUserSecretsProperty.targets | 0 .../clean-assets.cmd | 8 ++-- .../clean-assets.sh | 8 ++-- .../copyfiles.cmd | 8 ++-- .../copyfiles.sh | 10 ++--- .../copyfiles.cmd | 9 +++++ .../copyfiles.sh | 12 ++++++ .../project.json | 3 ++ 22 files changed, 73 insertions(+), 103 deletions(-) create mode 100644 src/Microsoft.DotNet.Watcher.Tools/prefercliruntime rename src/Microsoft.DotNet.Watcher.Tools/{tools => toolassets}/DotNetWatchCommon.targets (100%) rename src/Microsoft.DotNet.Watcher.Tools/{tools => toolassets}/DotNetWatchInner.targets (100%) rename src/Microsoft.DotNet.Watcher.Tools/{tools => toolassets}/DotNetWatchOuter.targets (100%) create mode 100644 src/Microsoft.Extensions.Caching.SqlConfig.Tools/prefercliruntime create mode 100644 src/Microsoft.Extensions.SecretManager.Tools/prefercliruntime rename src/Microsoft.Extensions.SecretManager.Tools/{ => toolassets}/FindUserSecretsProperty.targets (100%) create mode 100644 test/Microsoft.Extensions.SecretManager.Tools.Tests/copyfiles.cmd create mode 100755 test/Microsoft.Extensions.SecretManager.Tools.Tests/copyfiles.sh diff --git a/src/Microsoft.DotNet.Watcher.Tools/Internal/MsBuildFileSetFactory.cs b/src/Microsoft.DotNet.Watcher.Tools/Internal/MsBuildFileSetFactory.cs index 1ff1175f76..5aded8f772 100644 --- a/src/Microsoft.DotNet.Watcher.Tools/Internal/MsBuildFileSetFactory.cs +++ b/src/Microsoft.DotNet.Watcher.Tools/Internal/MsBuildFileSetFactory.cs @@ -164,8 +164,9 @@ namespace Microsoft.DotNet.Watcher.Internal { AppContext.BaseDirectory, assemblyDir, - Path.Combine(assemblyDir, "../../tools"), // from nuget cache - Path.Combine(assemblyDir, "tools") // from local build + Path.Combine(assemblyDir, "../../toolassets"), // from nuget cache + Path.Combine(assemblyDir, "toolassets"), // from local build + Path.Combine(AppContext.BaseDirectory, "../../toolassets"), // relative to packaged deps.json }; var targetPath = searchPaths.Select(p => Path.Combine(p, WatchTargetsFileName)).First(File.Exists); diff --git a/src/Microsoft.DotNet.Watcher.Tools/Microsoft.DotNet.Watcher.Tools.nuspec b/src/Microsoft.DotNet.Watcher.Tools/Microsoft.DotNet.Watcher.Tools.nuspec index 61ccec29df..22054d71df 100644 --- a/src/Microsoft.DotNet.Watcher.Tools/Microsoft.DotNet.Watcher.Tools.nuspec +++ b/src/Microsoft.DotNet.Watcher.Tools/Microsoft.DotNet.Watcher.Tools.nuspec @@ -19,12 +19,13 @@ + - - - - + + + + \ No newline at end of file diff --git a/src/Microsoft.DotNet.Watcher.Tools/prefercliruntime b/src/Microsoft.DotNet.Watcher.Tools/prefercliruntime new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Microsoft.DotNet.Watcher.Tools/project.json b/src/Microsoft.DotNet.Watcher.Tools/project.json index c60e93de77..945f21c9c5 100644 --- a/src/Microsoft.DotNet.Watcher.Tools/project.json +++ b/src/Microsoft.DotNet.Watcher.Tools/project.json @@ -1,22 +1,12 @@ { "version": "1.0.0-*", - "description": "Command line tool to watch for source file changes during development and restart the dotnet command.", - "packOptions": { - "tags": [ - "dotnet", - "watch" - ], - "files": { - "include": "tools/*.targets" - } - }, "buildOptions": { "outputName": "dotnet-watch", "warningsAsErrors": true, "emitEntryPoint": true, "debugType": "portable", "keyFile": "../../tools/Key.snk", - "copyToOutput": "tools/*.targets", + "copyToOutput": "toolassets/*.targets", "embed": { "mappings": { "dotnetwatch.targets": "dotnetwatch.targets" @@ -28,7 +18,8 @@ }, "publishOptions": { "include": [ - "tools/*.targets" + "toolassets/*.targets", + "prefercliruntime" ] }, "dependencies": { @@ -38,7 +29,7 @@ }, "Microsoft.NETCore.App": { "type": "platform", - "version": "1.0.1" + "version": "1.0.0" } }, "frameworks": { diff --git a/src/Microsoft.DotNet.Watcher.Tools/tools/DotNetWatchCommon.targets b/src/Microsoft.DotNet.Watcher.Tools/toolassets/DotNetWatchCommon.targets similarity index 100% rename from src/Microsoft.DotNet.Watcher.Tools/tools/DotNetWatchCommon.targets rename to src/Microsoft.DotNet.Watcher.Tools/toolassets/DotNetWatchCommon.targets diff --git a/src/Microsoft.DotNet.Watcher.Tools/tools/DotNetWatchInner.targets b/src/Microsoft.DotNet.Watcher.Tools/toolassets/DotNetWatchInner.targets similarity index 100% rename from src/Microsoft.DotNet.Watcher.Tools/tools/DotNetWatchInner.targets rename to src/Microsoft.DotNet.Watcher.Tools/toolassets/DotNetWatchInner.targets diff --git a/src/Microsoft.DotNet.Watcher.Tools/tools/DotNetWatchOuter.targets b/src/Microsoft.DotNet.Watcher.Tools/toolassets/DotNetWatchOuter.targets similarity index 100% rename from src/Microsoft.DotNet.Watcher.Tools/tools/DotNetWatchOuter.targets rename to src/Microsoft.DotNet.Watcher.Tools/toolassets/DotNetWatchOuter.targets diff --git a/src/Microsoft.Extensions.Caching.SqlConfig.Tools/Microsoft.Extensions.Caching.SqlConfig.Tools.nuspec b/src/Microsoft.Extensions.Caching.SqlConfig.Tools/Microsoft.Extensions.Caching.SqlConfig.Tools.nuspec index 4103770bb4..afe20d84d3 100644 --- a/src/Microsoft.Extensions.Caching.SqlConfig.Tools/Microsoft.Extensions.Caching.SqlConfig.Tools.nuspec +++ b/src/Microsoft.Extensions.Caching.SqlConfig.Tools/Microsoft.Extensions.Caching.SqlConfig.Tools.nuspec @@ -20,6 +20,7 @@ + diff --git a/src/Microsoft.Extensions.Caching.SqlConfig.Tools/prefercliruntime b/src/Microsoft.Extensions.Caching.SqlConfig.Tools/prefercliruntime new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Microsoft.Extensions.Caching.SqlConfig.Tools/project.json b/src/Microsoft.Extensions.Caching.SqlConfig.Tools/project.json index 27ce41031d..7fbfeae37d 100644 --- a/src/Microsoft.Extensions.Caching.SqlConfig.Tools/project.json +++ b/src/Microsoft.Extensions.Caching.SqlConfig.Tools/project.json @@ -6,23 +6,13 @@ "warningsAsErrors": true, "keyFile": "../../tools/Key.snk", "compile": "../Shared/**/*.cs" - }, - "description": "Command line tool to create tables and indexes in a Microsoft SQL Server database for distributed caching.", - "packOptions": { - "repository": { - "type": "git", - "url": "https://github.com/aspnet/DotNetTools" - }, - "tags": [ - "cache", - "distributedcache", - "sqlserver" - ] + "publishOptions": { + "include": "prefercliruntime" }, "dependencies": { "Microsoft.NETCore.App": { - "version": "1.0.1", + "version": "1.0.0", "type": "platform" }, "System.Data.SqlClient": "4.1.0" diff --git a/src/Microsoft.Extensions.SecretManager.Tools/Internal/ProjectIdResolver.cs b/src/Microsoft.Extensions.SecretManager.Tools/Internal/ProjectIdResolver.cs index 26de364cd5..2c891a3755 100644 --- a/src/Microsoft.Extensions.SecretManager.Tools/Internal/ProjectIdResolver.cs +++ b/src/Microsoft.Extensions.SecretManager.Tools/Internal/ProjectIdResolver.cs @@ -81,14 +81,6 @@ namespace Microsoft.Extensions.SecretManager.Tools.Internal return id; } - public void Dispose() - { - foreach (var file in _tempFiles) - { - TryDelete(file); - } - } - private string GetTargetFile() { var assemblyDir = Path.GetDirectoryName(GetType().GetTypeInfo().Assembly.Location); @@ -98,33 +90,23 @@ namespace Microsoft.Extensions.SecretManager.Tools.Internal { AppContext.BaseDirectory, assemblyDir, // next to assembly - Path.Combine(assemblyDir, "../../tools"), // inside the nupkg + Path.Combine(assemblyDir, "../../toolassets"), // inside the nupkg + Path.Combine(assemblyDir, "toolassets"), // for local builds + Path.Combine(AppContext.BaseDirectory, "../../toolassets"), // relative to packaged deps.json }; - var foundFile = searchPaths + return searchPaths .Select(dir => Path.Combine(dir, TargetsFileName)) .Where(File.Exists) - .FirstOrDefault(); + .First(); + } - if (foundFile != null) + public void Dispose() + { + foreach (var file in _tempFiles) { - return foundFile; + TryDelete(file); } - - // This should only really happen during testing. Current build system doesn't give us a good way to ensure the - // test project has an always-up to date version of the targets file. - // TODO cleanup after we switch to an MSBuild system in which can specify "CopyToOutputDirectory: Always" to resolve this issue - var outputPath = Path.GetTempFileName(); - using (var resource = GetType().GetTypeInfo().Assembly.GetManifestResourceStream(TargetsFileName)) - using (var stream = new FileStream(outputPath, FileMode.Create)) - { - resource.CopyTo(stream); - } - - // cleanup - _tempFiles.Add(outputPath); - - return outputPath; } private static void TryDelete(string file) diff --git a/src/Microsoft.Extensions.SecretManager.Tools/Microsoft.Extensions.SecretManager.Tools.nuspec b/src/Microsoft.Extensions.SecretManager.Tools/Microsoft.Extensions.SecretManager.Tools.nuspec index eb63c1592c..5d47660dd5 100644 --- a/src/Microsoft.Extensions.SecretManager.Tools/Microsoft.Extensions.SecretManager.Tools.nuspec +++ b/src/Microsoft.Extensions.SecretManager.Tools/Microsoft.Extensions.SecretManager.Tools.nuspec @@ -22,7 +22,8 @@ - + + diff --git a/src/Microsoft.Extensions.SecretManager.Tools/prefercliruntime b/src/Microsoft.Extensions.SecretManager.Tools/prefercliruntime new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Microsoft.Extensions.SecretManager.Tools/project.json b/src/Microsoft.Extensions.SecretManager.Tools/project.json index 4b188c420a..9b198d29f1 100644 --- a/src/Microsoft.Extensions.SecretManager.Tools/project.json +++ b/src/Microsoft.Extensions.SecretManager.Tools/project.json @@ -5,42 +5,21 @@ "emitEntryPoint": true, "warningsAsErrors": true, "keyFile": "../../tools/Key.snk", - "copyToOutput": "*.targets", - "embed": { - "mappings": { - "FindUserSecretsProperty.targets": "./FindUserSecretsProperty.targets" - } - }, + "copyToOutput": "toolassets/*.targets", "compile": { "include": "../Shared/**/*.cs" } }, - "description": "Command line tool to manage user secrets for Microsoft.Extensions.Configuration.", - "packOptions": { - "repository": { - "type": "git", - "url": "https://github.com/aspnet/DotNetTools" - }, - "tags": [ - "configuration", - "secrets", - "usersecrets" - ], - "files": { - "mappings": { - "tools/FindUserSecretsProperty.targets": "FindUserSecretsProperty.targets" - } - } - }, "publishOptions": { "include": [ - "*.targets" + "toolassets/*.targets", + "prefercliruntime" ] }, "dependencies": { "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0", "Microsoft.NETCore.App": { - "version": "1.0.1", + "version": "1.0.0", "type": "platform" } }, diff --git a/src/Microsoft.Extensions.SecretManager.Tools/FindUserSecretsProperty.targets b/src/Microsoft.Extensions.SecretManager.Tools/toolassets/FindUserSecretsProperty.targets similarity index 100% rename from src/Microsoft.Extensions.SecretManager.Tools/FindUserSecretsProperty.targets rename to src/Microsoft.Extensions.SecretManager.Tools/toolassets/FindUserSecretsProperty.targets diff --git a/test/Microsoft.DotNet.Watcher.Tools.FunctionalTests/clean-assets.cmd b/test/Microsoft.DotNet.Watcher.Tools.FunctionalTests/clean-assets.cmd index 2d1d41f1a8..f8999b5659 100644 --- a/test/Microsoft.DotNet.Watcher.Tools.FunctionalTests/clean-assets.cmd +++ b/test/Microsoft.DotNet.Watcher.Tools.FunctionalTests/clean-assets.cmd @@ -3,9 +3,9 @@ if not "%1" == "" ( echo "Deleting %1\TestProjects" rmdir /s /q %1\TestProjects - echo "Deleting %1\tools" - rmdir /s /q %1\tools + echo "Deleting %1\toolassets" + rmdir /s /q %1\toolassets ) -mkdir %1\tools -copy ..\..\src\Microsoft.DotNet.Watcher.Tools\tools\*.targets %1\tools \ No newline at end of file +mkdir %1\toolassets +copy ..\..\src\Microsoft.DotNet.Watcher.Tools\toolassets\*.targets %1\toolassets \ No newline at end of file diff --git a/test/Microsoft.DotNet.Watcher.Tools.FunctionalTests/clean-assets.sh b/test/Microsoft.DotNet.Watcher.Tools.FunctionalTests/clean-assets.sh index 5b096cd399..21b69ed268 100755 --- a/test/Microsoft.DotNet.Watcher.Tools.FunctionalTests/clean-assets.sh +++ b/test/Microsoft.DotNet.Watcher.Tools.FunctionalTests/clean-assets.sh @@ -4,11 +4,11 @@ if [ -z $1 ]; then echo "Deleting $1/TestProjects" rm -rf $1/TestProjects - echo "Deleting $1/tools" - rm -rf $1/tools + echo "Deleting $1/toolassets" + rm -rf $1/toolassets fi -mkdir -p $1/tools -cp ../../src/Microsoft.DotNet.Watcher.Tools/tools/*.targets $1/tools +mkdir -p $1/toolassets +cp ../../src/Microsoft.DotNet.Watcher.Tools/toolassets/*.targets $1/toolassets exit 0 \ No newline at end of file diff --git a/test/Microsoft.DotNet.Watcher.Tools.Tests/copyfiles.cmd b/test/Microsoft.DotNet.Watcher.Tools.Tests/copyfiles.cmd index 812690859e..6bd0489a90 100644 --- a/test/Microsoft.DotNet.Watcher.Tools.Tests/copyfiles.cmd +++ b/test/Microsoft.DotNet.Watcher.Tools.Tests/copyfiles.cmd @@ -1,9 +1,9 @@ @ECHO OFF :again if not "%1" == "" ( - echo "Deleting %1\tools" - rmdir /s /q %1\tools + echo "Deleting %1\toolassets" + rmdir /s /q %1\toolassets ) -mkdir %1\tools -copy ..\..\src\Microsoft.DotNet.Watcher.Tools\tools\*.targets %1\tools \ No newline at end of file +mkdir %1\toolassets +copy ..\..\src\Microsoft.DotNet.Watcher.Tools\toolassets\*.targets %1\toolassets \ No newline at end of file diff --git a/test/Microsoft.DotNet.Watcher.Tools.Tests/copyfiles.sh b/test/Microsoft.DotNet.Watcher.Tools.Tests/copyfiles.sh index 8c12918ae7..78ae5ff657 100755 --- a/test/Microsoft.DotNet.Watcher.Tools.Tests/copyfiles.sh +++ b/test/Microsoft.DotNet.Watcher.Tools.Tests/copyfiles.sh @@ -1,12 +1,12 @@ #!/usr/bin/env bash if [ -z $1 ]; then - echo "Deleting $1/tools" - rm -rf $1/tools + echo "Deleting $1/toolassets" + rm -rf $1/toolassets fi -mkdir -p $1/tools -echo "Copying ./../src/Microsoft.DotNet.Watcher.Tools/tools/*.targets" -cp ../../src/Microsoft.DotNet.Watcher.Tools/tools/*.targets $1/tools +mkdir -p $1/toolassets +echo "Copying ./../src/Microsoft.DotNet.Watcher.Tools/toolassets/*.targets" +cp ../../src/Microsoft.DotNet.Watcher.Tools/toolassets/*.targets $1/toolassets exit 0 \ No newline at end of file diff --git a/test/Microsoft.Extensions.SecretManager.Tools.Tests/copyfiles.cmd b/test/Microsoft.Extensions.SecretManager.Tools.Tests/copyfiles.cmd new file mode 100644 index 0000000000..7f24b7967f --- /dev/null +++ b/test/Microsoft.Extensions.SecretManager.Tools.Tests/copyfiles.cmd @@ -0,0 +1,9 @@ +@ECHO OFF +:again +if not "%1" == "" ( + echo "Deleting %1\toolassets" + rmdir /s /q %1\toolassets +) + +mkdir %1\toolassets +copy ..\..\src\Microsoft.Extensions.SecretManager.Tools\toolassets\*.targets %1\toolassets \ No newline at end of file diff --git a/test/Microsoft.Extensions.SecretManager.Tools.Tests/copyfiles.sh b/test/Microsoft.Extensions.SecretManager.Tools.Tests/copyfiles.sh new file mode 100755 index 0000000000..a1d6dfe373 --- /dev/null +++ b/test/Microsoft.Extensions.SecretManager.Tools.Tests/copyfiles.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +if [ -z $1 ]; then + echo "Deleting $1/toolassets" + rm -rf $1/toolassets +fi + +mkdir -p $1/toolassets +echo "Copying ./../src/Microsoft.Extensions.SecretManager.Tools/toolassets/*.targets" +cp ../../src/Microsoft.Extensions.SecretManager.Tools/toolassets/*.targets $1/toolassets + +exit 0 \ No newline at end of file diff --git a/test/Microsoft.Extensions.SecretManager.Tools.Tests/project.json b/test/Microsoft.Extensions.SecretManager.Tools.Tests/project.json index 5cc4eeb1b1..f0095bea8d 100644 --- a/test/Microsoft.Extensions.SecretManager.Tools.Tests/project.json +++ b/test/Microsoft.Extensions.SecretManager.Tools.Tests/project.json @@ -20,5 +20,8 @@ } } } + }, + "scripts": { + "precompile": "copyfiles %compile:OutputDir%" } } \ No newline at end of file