diff --git a/RazorTooling.sln b/RazorTooling.sln index 85fdca9..1a29aff 100644 --- a/RazorTooling.sln +++ b/RazorTooling.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.24720.0 +VisualStudioVersion = 14.0.25420.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{253024B2-368B-4B24-9CD3-D48E9C1EC948}" EndProject @@ -12,30 +12,51 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{8D49C692-BA71-43C4-927F-E9E2BA8FC795}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Razor.Tools.Test", "test\Microsoft.AspNetCore.Razor.Tools.Test\Microsoft.AspNetCore.Razor.Tools.Test.xproj", "{AB04D3BA-0A35-4502-AD4F-E8D1B38A6E5B}" -EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Razor.Tools", "src\Microsoft.AspNetCore.Razor.Tools\Microsoft.AspNetCore.Razor.Tools.xproj", "{6F1CAB8C-2315-46BB-B9B4-00564743590C}" EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Razor.Design", "src\Microsoft.AspNetCore.Razor.Design\Microsoft.AspNetCore.Razor.Design.xproj", "{60043E40-0D14-4E41-A97A-52A7A1BB5A26}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Razor.Design.Test", "test\Microsoft.AspNetCore.Razor.Design.Test\Microsoft.AspNetCore.Razor.Design.Test.xproj", "{C4279BCD-DADD-4354-B28D-B7FE24BAD230}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + debug_x86|Any CPU = debug_x86|Any CPU Debug|Any CPU = Debug|Any CPU + release_x86|Any CPU = release_x86|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {AB04D3BA-0A35-4502-AD4F-E8D1B38A6E5B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AB04D3BA-0A35-4502-AD4F-E8D1B38A6E5B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AB04D3BA-0A35-4502-AD4F-E8D1B38A6E5B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AB04D3BA-0A35-4502-AD4F-E8D1B38A6E5B}.Release|Any CPU.Build.0 = Release|Any CPU + {6F1CAB8C-2315-46BB-B9B4-00564743590C}.debug_x86|Any CPU.ActiveCfg = Debug|Any CPU + {6F1CAB8C-2315-46BB-B9B4-00564743590C}.debug_x86|Any CPU.Build.0 = Debug|Any CPU {6F1CAB8C-2315-46BB-B9B4-00564743590C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6F1CAB8C-2315-46BB-B9B4-00564743590C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6F1CAB8C-2315-46BB-B9B4-00564743590C}.release_x86|Any CPU.ActiveCfg = Release|Any CPU + {6F1CAB8C-2315-46BB-B9B4-00564743590C}.release_x86|Any CPU.Build.0 = Release|Any CPU {6F1CAB8C-2315-46BB-B9B4-00564743590C}.Release|Any CPU.ActiveCfg = Release|Any CPU {6F1CAB8C-2315-46BB-B9B4-00564743590C}.Release|Any CPU.Build.0 = Release|Any CPU + {60043E40-0D14-4E41-A97A-52A7A1BB5A26}.debug_x86|Any CPU.ActiveCfg = debug_x86|Any CPU + {60043E40-0D14-4E41-A97A-52A7A1BB5A26}.debug_x86|Any CPU.Build.0 = debug_x86|Any CPU + {60043E40-0D14-4E41-A97A-52A7A1BB5A26}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {60043E40-0D14-4E41-A97A-52A7A1BB5A26}.Debug|Any CPU.Build.0 = Debug|Any CPU + {60043E40-0D14-4E41-A97A-52A7A1BB5A26}.release_x86|Any CPU.ActiveCfg = release_x86|Any CPU + {60043E40-0D14-4E41-A97A-52A7A1BB5A26}.release_x86|Any CPU.Build.0 = release_x86|Any CPU + {60043E40-0D14-4E41-A97A-52A7A1BB5A26}.Release|Any CPU.ActiveCfg = Release|Any CPU + {60043E40-0D14-4E41-A97A-52A7A1BB5A26}.Release|Any CPU.Build.0 = Release|Any CPU + {C4279BCD-DADD-4354-B28D-B7FE24BAD230}.debug_x86|Any CPU.ActiveCfg = Debug|Any CPU + {C4279BCD-DADD-4354-B28D-B7FE24BAD230}.debug_x86|Any CPU.Build.0 = Debug|Any CPU + {C4279BCD-DADD-4354-B28D-B7FE24BAD230}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C4279BCD-DADD-4354-B28D-B7FE24BAD230}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C4279BCD-DADD-4354-B28D-B7FE24BAD230}.release_x86|Any CPU.ActiveCfg = Release|Any CPU + {C4279BCD-DADD-4354-B28D-B7FE24BAD230}.release_x86|Any CPU.Build.0 = Release|Any CPU + {C4279BCD-DADD-4354-B28D-B7FE24BAD230}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C4279BCD-DADD-4354-B28D-B7FE24BAD230}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {AB04D3BA-0A35-4502-AD4F-E8D1B38A6E5B} = {8D49C692-BA71-43C4-927F-E9E2BA8FC795} {6F1CAB8C-2315-46BB-B9B4-00564743590C} = {253024B2-368B-4B24-9CD3-D48E9C1EC948} + {60043E40-0D14-4E41-A97A-52A7A1BB5A26} = {253024B2-368B-4B24-9CD3-D48E9C1EC948} + {C4279BCD-DADD-4354-B28D-B7FE24BAD230} = {8D49C692-BA71-43C4-927F-E9E2BA8FC795} EndGlobalSection EndGlobal diff --git a/makefile.shade b/makefile.shade index ec0b97b..1f3ecb8 100644 --- a/makefile.shade +++ b/makefile.shade @@ -5,8 +5,8 @@ use namespace="System.Linq" default CONFIGURATION_LOCAL='${E("Configuration")}' default BASE_DIR_LOCAL='${Directory.GetCurrentDirectory()}' default BUILD_DIR_LOCAL='${Path.Combine(BASE_DIR_LOCAL, "artifacts", "build")}' -default TOOL_PROJECT_NAME='Microsoft.AspNetCore.Razor.Tools' -default TOOL_EXE_NAME='dotnet-razor-tooling.exe' +default TOOL_PROJECT_NAME='Microsoft.AspNetCore.Razor.Design' +default TOOL_EXE_NAME='Microsoft.AspNetCore.Razor.Design.exe' var VERSION='0.1' var FULL_VERSION='0.1' var AUTHORS='Microsoft Open Technologies, Inc.' diff --git a/src/Microsoft.AspNetCore.Razor.Tools/Resources.Designer.cs b/src/Microsoft.AspNetCore.Razor.Design/DesignResources.Designer.cs similarity index 78% rename from src/Microsoft.AspNetCore.Razor.Tools/Resources.Designer.cs rename to src/Microsoft.AspNetCore.Razor.Design/DesignResources.Designer.cs index a022c8f..28aba36 100644 --- a/src/Microsoft.AspNetCore.Razor.Tools/Resources.Designer.cs +++ b/src/Microsoft.AspNetCore.Razor.Design/DesignResources.Designer.cs @@ -8,11 +8,11 @@ // //------------------------------------------------------------------------------ -namespace Microsoft.AspNetCore.Razor.Tools { +namespace Microsoft.AspNetCore.Razor.Design { using System; using System.Reflection; - - + + /// /// A strongly-typed resource class, for looking up localized strings, etc. /// @@ -22,15 +22,15 @@ namespace Microsoft.AspNetCore.Razor.Tools { // with the /str option, or rebuild your VS project. [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - public class Resources { - + public class DesignResources { + private static global::System.Resources.ResourceManager resourceMan; - + private static global::System.Globalization.CultureInfo resourceCulture; - - internal Resources() { + + internal DesignResources() { } - + /// /// Returns the cached ResourceManager instance used by this class. /// @@ -38,13 +38,13 @@ namespace Microsoft.AspNetCore.Razor.Tools { public static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.AspNetCore.Razor.Tools.Resources", typeof(Resources).GetTypeInfo().Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.AspNetCore.Razor.Design.DesignResources", typeof(DesignResources).GetTypeInfo().Assembly); resourceMan = temp; } return resourceMan; } } - + /// /// Overrides the current thread's CurrentUICulture property for all /// resource lookups using this strongly typed resource class. @@ -58,7 +58,16 @@ namespace Microsoft.AspNetCore.Razor.Tools { resourceCulture = value; } } - + + /// + /// Looks up a localized string similar to Could not invoke tool. Ensure project.json has matching versions of '{0}' in the 'dependencies' section and '{1}' in the 'tools' section.. + /// + public static string CouldNotInvokeTool { + get { + return ResourceManager.GetString("CouldNotInvokeTool", resourceCulture); + } + } + /// /// Looks up a localized string similar to Could not parse provided protocol '{0}'. Protocols should be valid int32 values.. /// @@ -67,16 +76,7 @@ namespace Microsoft.AspNetCore.Razor.Tools { return ResourceManager.GetString("CouldNotParseProvidedProtocol", resourceCulture); } } - - /// - /// Looks up a localized string similar to Failed to execute razor-tooling: '{0}'.. - /// - public static string FailedToExecuteRazorTooling { - get { - return ResourceManager.GetString("FailedToExecuteRazorTooling", resourceCulture); - } - } - + /// /// Looks up a localized string similar to '{0}'s cannot be resolved with protocol '{1}'. Protocol not supported.. /// @@ -85,14 +85,5 @@ namespace Microsoft.AspNetCore.Razor.Tools { return ResourceManager.GetString("InvalidProtocolValue", resourceCulture); } } - - /// - /// Looks up a localized string similar to Project '{0}' does not support the provided framework '{1}'.. - /// - public static string ProjectDoesNotSupportProvidedFramework { - get { - return ResourceManager.GetString("ProjectDoesNotSupportProvidedFramework", resourceCulture); - } - } } } diff --git a/src/Microsoft.AspNetCore.Razor.Tools/Resources.resx b/src/Microsoft.AspNetCore.Razor.Design/DesignResources.resx similarity index 95% rename from src/Microsoft.AspNetCore.Razor.Tools/Resources.resx rename to src/Microsoft.AspNetCore.Razor.Design/DesignResources.resx index 316957d..90e8f8c 100644 --- a/src/Microsoft.AspNetCore.Razor.Tools/Resources.resx +++ b/src/Microsoft.AspNetCore.Razor.Design/DesignResources.resx @@ -117,16 +117,13 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Could not invoke tool. Ensure project.json has matching versions of '{0}' in the 'dependencies' section and '{1}' in the 'tools' section. + Could not parse provided protocol '{0}'. Protocols should be valid int32 values. - - Failed to execute razor-tooling: '{0}'. - '{0}'s cannot be resolved with protocol '{1}'. Protocol not supported. - - Project '{0}' does not support the provided framework '{1}'. - \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Razor.Tools/Internal/AssemblyTagHelperDescriptorResolver.cs b/src/Microsoft.AspNetCore.Razor.Design/Internal/AssemblyTagHelperDescriptorResolver.cs similarity index 95% rename from src/Microsoft.AspNetCore.Razor.Tools/Internal/AssemblyTagHelperDescriptorResolver.cs rename to src/Microsoft.AspNetCore.Razor.Design/Internal/AssemblyTagHelperDescriptorResolver.cs index 870cb1e..85c6b20 100644 --- a/src/Microsoft.AspNetCore.Razor.Tools/Internal/AssemblyTagHelperDescriptorResolver.cs +++ b/src/Microsoft.AspNetCore.Razor.Design/Internal/AssemblyTagHelperDescriptorResolver.cs @@ -7,7 +7,7 @@ using System.Globalization; using Microsoft.AspNetCore.Razor.Compilation.TagHelpers; using Microsoft.AspNetCore.Razor.Runtime.TagHelpers; -namespace Microsoft.AspNetCore.Razor.Tools.Internal +namespace Microsoft.AspNetCore.Razor.Design.Internal { public class AssemblyTagHelperDescriptorResolver { @@ -53,7 +53,7 @@ namespace Microsoft.AspNetCore.Razor.Tools.Internal throw new InvalidOperationException( string.Format( CultureInfo.CurrentCulture, - Resources.InvalidProtocolValue, + DesignResources.InvalidProtocolValue, typeof(TagHelperDescriptor).FullName, ProtocolVersion)); } } diff --git a/src/Microsoft.AspNetCore.Razor.Tools/Internal/ResolveProtocolCommand.cs b/src/Microsoft.AspNetCore.Razor.Design/Internal/ResolveProtocolCommand.cs similarity index 82% rename from src/Microsoft.AspNetCore.Razor.Tools/Internal/ResolveProtocolCommand.cs rename to src/Microsoft.AspNetCore.Razor.Design/Internal/ResolveProtocolCommand.cs index 44a6db1..2d78a69 100644 --- a/src/Microsoft.AspNetCore.Razor.Tools/Internal/ResolveProtocolCommand.cs +++ b/src/Microsoft.AspNetCore.Razor.Design/Internal/ResolveProtocolCommand.cs @@ -3,15 +3,13 @@ using System; using System.Globalization; -using Microsoft.AspNetCore.Razor.Tools; -using Microsoft.DotNet.Cli.Utils; using Microsoft.Extensions.CommandLineUtils; -namespace Microsoft.AspNetCore.Razor.Tools.Internal +namespace Microsoft.AspNetCore.Razor.Design.Internal { public static class ResolveProtocolCommand { - internal static void Register(CommandLineApplication app) + public static void Register(CommandLineApplication app) { app.Command("resolve-protocol", config => { @@ -28,17 +26,17 @@ namespace Microsoft.AspNetCore.Razor.Tools.Internal int clientProtocol; if (!int.TryParse(clientProtocolString, out clientProtocol)) { - Reporter.Error.WriteLine( + Console.Error.WriteLine( string.Format( CultureInfo.CurrentCulture, - Resources.CouldNotParseProvidedProtocol, + DesignResources.CouldNotParseProvidedProtocol, clientProtocolString)); return 1; } var resolvedProtocol = ResolveProtocol(clientProtocol, pluginProtocol); - Reporter.Output.WriteLine(resolvedProtocol.ToString(CultureInfo.InvariantCulture)); + Console.WriteLine(resolvedProtocol.ToString(CultureInfo.InvariantCulture)); return 0; }); diff --git a/src/Microsoft.AspNetCore.Razor.Design/Microsoft.AspNetCore.Razor.Design.xproj b/src/Microsoft.AspNetCore.Razor.Design/Microsoft.AspNetCore.Razor.Design.xproj new file mode 100644 index 0000000..ab25dbd --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Design/Microsoft.AspNetCore.Razor.Design.xproj @@ -0,0 +1,18 @@ + + + + 14.0.25413 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + 60043e40-0d14-4e41-a97a-52a7a1bb5a26 + .\obj + .\bin\ + + + + 2.0 + + + \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Razor.Design/Program.cs b/src/Microsoft.AspNetCore.Razor.Design/Program.cs new file mode 100644 index 0000000..3106339 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Design/Program.cs @@ -0,0 +1,70 @@ +// 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 System.Globalization; +using System.Linq; +using System.Reflection; + +namespace Microsoft.AspNetCore.Razor.Design +{ + public class Program + { + private readonly static Type ProgramType = typeof(Program); + + public static int Main(string[] args) + { + var app = new RazorToolingApplication(ProgramType); + + EnsureValidDispatchRecipient(ref args); + + ResolveTagHelpersCommandBase.Register(app); + + return app.Execute(args); + } + + private static void EnsureValidDispatchRecipient(ref string[] args) + { + const string DispatcherVersionArgumentName = "--dispatcher-version"; + + if (!args.Contains(DispatcherVersionArgumentName, StringComparer.OrdinalIgnoreCase)) + { + return; + } + + var dispatcherArgumentIndex = Array.FindIndex( + args, + (value) => string.Equals(value, DispatcherVersionArgumentName, StringComparison.OrdinalIgnoreCase)); + var dispatcherArgumentValueIndex = dispatcherArgumentIndex + 1; + if (dispatcherArgumentValueIndex < args.Length) + { + var dispatcherVersion = args[dispatcherArgumentValueIndex]; + + var thisAssembly = ProgramType.GetTypeInfo().Assembly; + var version = thisAssembly.GetCustomAttribute() + ?.InformationalVersion + ?? thisAssembly.GetName().Version.ToString(); + + if (string.Equals(dispatcherVersion, version, StringComparison.Ordinal)) + { + // Remove dispatcher arguments from + var preDispatcherArgument = args.Take(dispatcherArgumentIndex); + var postDispatcherArgument = args.Skip(dispatcherArgumentIndex + 2); + var newProgramArguments = preDispatcherArgument.Concat(postDispatcherArgument); + args = newProgramArguments.ToArray(); + return; + } + } + + var thisAssemblyName = typeof(Program).GetTypeInfo().Assembly.GetName().Name; + + // Could not validate the dispatcher version. + throw new InvalidOperationException( + string.Format( + CultureInfo.CurrentCulture, + DesignResources.CouldNotInvokeTool, + thisAssemblyName, + "Microsoft.AspNetCore.Razor.Tools")); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Razor.Design/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Razor.Design/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..76fecee --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Design/Properties/AssemblyInfo.cs @@ -0,0 +1,11 @@ +// 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.Reflection; +using System.Resources; + +[assembly: AssemblyMetadata("Serviceable", "True")] +[assembly: NeutralResourcesLanguage("en-us")] +[assembly: AssemblyCompany("Microsoft Corporation.")] +[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] +[assembly: AssemblyProduct("Microsoft ASP.NET Core")] diff --git a/src/Microsoft.AspNetCore.Razor.Design/RazorToolingApplication.cs b/src/Microsoft.AspNetCore.Razor.Design/RazorToolingApplication.cs new file mode 100644 index 0000000..b1f000d --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Design/RazorToolingApplication.cs @@ -0,0 +1,61 @@ +// 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 System.Reflection; +using Microsoft.AspNetCore.Razor.Design.Internal; +using Microsoft.Extensions.CommandLineUtils; + +namespace Microsoft.AspNetCore.Razor.Design +{ + public class RazorToolingApplication : CommandLineApplication + { + private readonly Type _callingType; + + public RazorToolingApplication(Type callingType) + { + _callingType = callingType; + + Name = "razor-tooling"; + FullName = "Microsoft Razor Tooling Utility"; + Description = "Resolves Razor tooling specific information."; + ShortVersionGetter = GetInformationalVersion; + + HelpOption("-?|-h|--help"); + + OnExecute(() => + { + ShowHelp(); + return 2; + }); + + ResolveProtocolCommand.Register(this); + } + + public new int Execute(params string[] args) + { + try + { + return base.Execute(args); + } + catch (Exception ex) + { + Console.Error.WriteLine(ex.Message); + return 1; + } + } + + private string GetInformationalVersion() + { + var assembly = _callingType.GetTypeInfo().Assembly; + var attributes = assembly.GetCustomAttributes( + typeof(AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute[]; + + var versionAttribute = attributes.Length == 0 ? + assembly.GetName().Version.ToString() : + attributes[0].InformationalVersion; + + return versionAttribute; + } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Tools/Internal/ResolveTagHelpersCommandBase.cs b/src/Microsoft.AspNetCore.Razor.Design/ResolveTagHelpersCommandBase.cs similarity index 93% rename from src/Microsoft.AspNetCore.Razor.Tools/Internal/ResolveTagHelpersCommandBase.cs rename to src/Microsoft.AspNetCore.Razor.Design/ResolveTagHelpersCommandBase.cs index d981ecc..732a2a4 100644 --- a/src/Microsoft.AspNetCore.Razor.Tools/Internal/ResolveTagHelpersCommandBase.cs +++ b/src/Microsoft.AspNetCore.Razor.Design/ResolveTagHelpersCommandBase.cs @@ -3,13 +3,11 @@ using System; using System.Collections.Generic; -using Microsoft.AspNetCore.Razor; using Microsoft.AspNetCore.Razor.Compilation.TagHelpers; -using Microsoft.DotNet.Cli.Utils; using Microsoft.Extensions.CommandLineUtils; using Newtonsoft.Json; -namespace Microsoft.AspNetCore.Razor.Tools.Internal +namespace Microsoft.AspNetCore.Razor.Design { public abstract class ResolveTagHelpersCommandBase { @@ -42,7 +40,7 @@ namespace Microsoft.AspNetCore.Razor.Tools.Internal var serializedResult = JsonConvert.SerializeObject(resolvedResult, Formatting.Indented); - Reporter.Output.WriteLine(serializedResult); + Console.WriteLine(serializedResult); } protected void ReportError(string message) diff --git a/src/Microsoft.AspNetCore.Razor.Tools/Internal/ResolveTagHelpersRunCommand.cs b/src/Microsoft.AspNetCore.Razor.Design/ResolveTagHelpersRunCommand.cs similarity index 91% rename from src/Microsoft.AspNetCore.Razor.Tools/Internal/ResolveTagHelpersRunCommand.cs rename to src/Microsoft.AspNetCore.Razor.Design/ResolveTagHelpersRunCommand.cs index b89a1e6..280829d 100644 --- a/src/Microsoft.AspNetCore.Razor.Tools/Internal/ResolveTagHelpersRunCommand.cs +++ b/src/Microsoft.AspNetCore.Razor.Design/ResolveTagHelpersRunCommand.cs @@ -4,8 +4,9 @@ using System.Collections.Generic; using System.Globalization; using Microsoft.AspNetCore.Razor.Compilation.TagHelpers; +using Microsoft.AspNetCore.Razor.Design.Internal; -namespace Microsoft.AspNetCore.Razor.Tools.Internal +namespace Microsoft.AspNetCore.Razor.Design { public class ResolveTagHelpersRunCommand : ResolveTagHelpersCommandBase { @@ -20,7 +21,7 @@ namespace Microsoft.AspNetCore.Razor.Tools.Internal ReportError( string.Format( CultureInfo.CurrentCulture, - Resources.CouldNotParseProvidedProtocol, + DesignResources.CouldNotParseProvidedProtocol, protocolOptionValue)); return 0; } diff --git a/src/Microsoft.AspNetCore.Razor.Design/project.json b/src/Microsoft.AspNetCore.Razor.Design/project.json new file mode 100644 index 0000000..7f06099 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Design/project.json @@ -0,0 +1,54 @@ +{ + "version": "1.0.0-*", + "description": "Design-time components for Razor tooling.", + "packOptions": { + "repository": { + "type": "git", + "url": "git://github.com/AspNet/RazorTooling" + }, + "tags": [ + "cshtml", + "razor", + "taghelper", + "aspnetcore", + "taghelpers" + ] + }, + "buildOptions": { + "keyFile": "../../tools/Key.snk", + "warningsAsErrors": true, + "emitEntryPoint": true, + "nowarn": [ + "CS1591" + ], + "xmlDoc": true + }, + "configurations": { + "debug_x86": { + "buildOptions": { + "platform": "anycpu32bitpreferred" + } + }, + "release_x86": { + "buildOptions": { + "platform": "anycpu32bitpreferred" + } + } + }, + "dependencies": { + "Microsoft.AspNetCore.Razor.Runtime": "1.1.0-*", + "Microsoft.Extensions.CommandLineUtils": "1.1.0-*", + "Newtonsoft.Json": "9.0.1" + }, + "frameworks": { + "netcoreapp1.0": { + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.0-*" + } + } + }, + "net451": {} + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Razor.Tools/Internal/PackageOnlyResolveTagHelpersRunCommand.cs b/src/Microsoft.AspNetCore.Razor.Tools/Internal/PackageOnlyResolveTagHelpersRunCommand.cs index 1d42586..7a76f8c 100644 --- a/src/Microsoft.AspNetCore.Razor.Tools/Internal/PackageOnlyResolveTagHelpersRunCommand.cs +++ b/src/Microsoft.AspNetCore.Razor.Tools/Internal/PackageOnlyResolveTagHelpersRunCommand.cs @@ -8,6 +8,8 @@ using System.IO; using System.Linq; using System.Reflection; using System.Runtime.Loader; +using Microsoft.AspNetCore.Razor.Design; +using Microsoft.AspNetCore.Razor.Design.Internal; using Microsoft.AspNetCore.Razor.Runtime.TagHelpers; using Microsoft.DotNet.Cli.Utils; using Microsoft.DotNet.InternalAbstractions; diff --git a/src/Microsoft.AspNetCore.Razor.Tools/Internal/ResolveTagHelpersDispatchCommand.cs b/src/Microsoft.AspNetCore.Razor.Tools/Internal/ResolveTagHelpersDispatchCommand.cs index 9ce304b..74a7eb6 100644 --- a/src/Microsoft.AspNetCore.Razor.Tools/Internal/ResolveTagHelpersDispatchCommand.cs +++ b/src/Microsoft.AspNetCore.Razor.Tools/Internal/ResolveTagHelpersDispatchCommand.cs @@ -5,6 +5,8 @@ using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; +using System.Reflection; +using Microsoft.AspNetCore.Razor.Design; using Microsoft.DotNet.ProjectModel; using Microsoft.Extensions.CommandLineUtils; using Microsoft.Extensions.Internal; @@ -84,13 +86,15 @@ namespace Microsoft.AspNetCore.Razor.Tools.Internal dispatchArgs.Add(ProtocolOption.Value()); } + var toolName = typeof(Design.Program).GetTypeInfo().Assembly.GetName().Name; var dispatchCommand = DotnetToolDispatcher.CreateDispatchCommand( dispatchArgs, framework, ConfigurationOption.Value(), outputPath: null, buildBasePath: BuildBasePathOption.Value(), - projectDirectory: projectFile.ProjectDirectory); + projectDirectory: projectFile.ProjectDirectory, + toolName: toolName); using (var errorWriter = new StringWriter()) { @@ -105,7 +109,7 @@ namespace Microsoft.AspNetCore.Razor.Tools.Internal ReportError( string.Format( CultureInfo.CurrentCulture, - Resources.FailedToExecuteRazorTooling, + ToolResources.FailedToExecuteRazorTooling, errorWriter.ToString())); } @@ -128,7 +132,7 @@ namespace Microsoft.AspNetCore.Razor.Tools.Internal ReportError( string.Format( CultureInfo.CurrentCulture, - Resources.ProjectDoesNotSupportProvidedFramework, + ToolResources.ProjectDoesNotSupportProvidedFramework, ProjectArgument.Value, frameworkOptionValue)); diff --git a/src/Microsoft.AspNetCore.Razor.Tools/Microsoft.AspNetCore.Razor.Tools.xproj b/src/Microsoft.AspNetCore.Razor.Tools/Microsoft.AspNetCore.Razor.Tools.xproj index 9b7c04a..ebb9e65 100644 --- a/src/Microsoft.AspNetCore.Razor.Tools/Microsoft.AspNetCore.Razor.Tools.xproj +++ b/src/Microsoft.AspNetCore.Razor.Tools/Microsoft.AspNetCore.Razor.Tools.xproj @@ -1,17 +1,18 @@  - + - 14.0 + 14.0.25413 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - + 6f1cab8c-2315-46bb-b9b4-00564743590c - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\ + .\obj + .\bin\ + 2.0 - + \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Razor.Tools/Program.cs b/src/Microsoft.AspNetCore.Razor.Tools/Program.cs index 6ceeb83..57461ba 100644 --- a/src/Microsoft.AspNetCore.Razor.Tools/Program.cs +++ b/src/Microsoft.AspNetCore.Razor.Tools/Program.cs @@ -1,12 +1,8 @@ // 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 System.Reflection; +using Microsoft.AspNetCore.Razor.Design; using Microsoft.AspNetCore.Razor.Tools.Internal; -using Microsoft.DotNet.Cli.Utils; -using Microsoft.Extensions.CommandLineUtils; -using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Razor.Tools { @@ -14,56 +10,11 @@ namespace Microsoft.AspNetCore.Razor.Tools { public static int Main(string[] args) { - try - { - var app = new CommandLineApplication - { - Name = "razor-tooling", - FullName = "Microsoft Razor Tooling Utility", - Description = "Resolves Razor tooling specific information.", - ShortVersionGetter = GetInformationalVersion, - }; - app.HelpOption("-?|-h|--help"); + var app = new RazorToolingApplication(typeof(Program)); - ResolveProtocolCommand.Register(app); + ResolveTagHelpersCommandBase.Register(app); - if (DotnetToolDispatcher.IsDispatcher(args)) - { - ResolveTagHelpersCommandBase.Register(app); - } - else - { - DotnetToolDispatcher.EnsureValidDispatchRecipient(ref args); - - ResolveTagHelpersCommandBase.Register(app); - } - - app.OnExecute(() => - { - app.ShowHelp(); - return 2; - }); - - return app.Execute(args); - } - catch (Exception ex) - { - Reporter.Error.WriteLine(ex.Message); - return 1; - } - } - - private static string GetInformationalVersion() - { - var assembly = typeof(Program).GetTypeInfo().Assembly; - var attributes = assembly.GetCustomAttributes( - typeof(AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute[]; - - var versionAttribute = attributes.Length == 0 ? - assembly.GetName().Version.ToString() : - attributes[0].InformationalVersion; - - return versionAttribute; + return app.Execute(args); } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Razor.Tools/ToolResources.Designer.cs b/src/Microsoft.AspNetCore.Razor.Tools/ToolResources.Designer.cs new file mode 100644 index 0000000..7b87e3d --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Tools/ToolResources.Designer.cs @@ -0,0 +1,80 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Microsoft.AspNetCore.Razor.Tools { + using System; + using System.Reflection; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class ToolResources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + internal ToolResources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.AspNetCore.Razor.Tools.ToolResources", typeof(ToolResources).GetTypeInfo().Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Failed to execute razor-tooling: '{0}'.. + /// + public static string FailedToExecuteRazorTooling { + get { + return ResourceManager.GetString("FailedToExecuteRazorTooling", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Project '{0}' does not support the provided framework '{1}'.. + /// + public static string ProjectDoesNotSupportProvidedFramework { + get { + return ResourceManager.GetString("ProjectDoesNotSupportProvidedFramework", resourceCulture); + } + } + } +} diff --git a/src/Microsoft.AspNetCore.Razor.Tools/ToolResources.resx b/src/Microsoft.AspNetCore.Razor.Tools/ToolResources.resx new file mode 100644 index 0000000..54ec395 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Tools/ToolResources.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Failed to execute razor-tooling: '{0}'. + + + Project '{0}' does not support the provided framework '{1}'. + + \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Razor.Tools/project.json b/src/Microsoft.AspNetCore.Razor.Tools/project.json index 7a4d345..bac13e3 100644 --- a/src/Microsoft.AspNetCore.Razor.Tools/project.json +++ b/src/Microsoft.AspNetCore.Razor.Tools/project.json @@ -24,28 +24,13 @@ ], "xmlDoc": true }, - "configurations": { - "debug_x86": { - "buildOptions": { - "platform": "anycpu32bitpreferred" - } - }, - "release_x86": { - "buildOptions": { - "platform": "anycpu32bitpreferred" - } - } - }, "dependencies": { - "Microsoft.AspNetCore.Razor.Runtime": "1.1.0-*", + "Microsoft.AspNetCore.Razor.Design": "1.0.0-*", "Microsoft.DotNet.Cli.Utils": "1.0.0-*", - "Microsoft.Extensions.CommandLineUtils": "1.1.0-*", "Microsoft.Extensions.DotnetToolDispatcher.Sources": { "type": "build", "version": "1.1.0-*" - }, - "Microsoft.Extensions.PlatformAbstractions": "1.1.0-*", - "Newtonsoft.Json": "9.0.1" + } }, "frameworks": { "netcoreapp1.0": { diff --git a/test/Microsoft.AspNetCore.Razor.Tools.Test/AssemblyTagHelperDescriptorResolverTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/Internal/AssemblyTagHelperDescriptorResolverTest.cs similarity index 97% rename from test/Microsoft.AspNetCore.Razor.Tools.Test/AssemblyTagHelperDescriptorResolverTest.cs rename to test/Microsoft.AspNetCore.Razor.Design.Test/Internal/AssemblyTagHelperDescriptorResolverTest.cs index 864413a..1d7020d 100644 --- a/test/Microsoft.AspNetCore.Razor.Tools.Test/AssemblyTagHelperDescriptorResolverTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/Internal/AssemblyTagHelperDescriptorResolverTest.cs @@ -4,17 +4,14 @@ using System; using System.Collections.Generic; using System.Reflection; -using System.Runtime.Loader; -using Microsoft.AspNetCore.Razor; using Microsoft.AspNetCore.Razor.Compilation.TagHelpers; using Microsoft.AspNetCore.Razor.TagHelpers; using Microsoft.AspNetCore.Razor.Test.Internal; -using Microsoft.AspNetCore.Razor.Tools.Internal; using Xunit; -namespace Microsoft.AspNetCore.Tooling.Razor +namespace Microsoft.AspNetCore.Razor.Design.Internal { - public class RazorPluginTest + public class AssemblyTagHelperDescriptorResolverTest { private const string DefaultPrefix = ""; diff --git a/test/Microsoft.AspNetCore.Razor.Tools.Test/ResolveProtocolCommandTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/Internal/ResolveProtocolCommandTest.cs similarity index 89% rename from test/Microsoft.AspNetCore.Razor.Tools.Test/ResolveProtocolCommandTest.cs rename to test/Microsoft.AspNetCore.Razor.Design.Test/Internal/ResolveProtocolCommandTest.cs index ec52f51..a94def6 100644 --- a/test/Microsoft.AspNetCore.Razor.Tools.Test/ResolveProtocolCommandTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/Internal/ResolveProtocolCommandTest.cs @@ -1,10 +1,9 @@ // 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 Microsoft.AspNetCore.Razor.Tools.Internal; using Xunit; -namespace Microsoft.AspNetCore.Razor.Tools +namespace Microsoft.AspNetCore.Razor.Design.Internal { public class ResolveProtocolCommandTest { diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/Microsoft.AspNetCore.Razor.Design.Test.xproj b/test/Microsoft.AspNetCore.Razor.Design.Test/Microsoft.AspNetCore.Razor.Design.Test.xproj new file mode 100644 index 0000000..10983a7 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/Microsoft.AspNetCore.Razor.Design.Test.xproj @@ -0,0 +1,21 @@ + + + + 14.0.25413 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + c4279bcd-dadd-4354-b28d-b7fe24bad230 + Microsoft.AspNetCore.Razor.Design.Test + .\obj + .\bin\ + + + 2.0 + + + + + + \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Razor.Tools.Test/VisualStudioProtocolTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/VisualStudioProtocolTest.cs similarity index 99% rename from test/Microsoft.AspNetCore.Razor.Tools.Test/VisualStudioProtocolTest.cs rename to test/Microsoft.AspNetCore.Razor.Design.Test/VisualStudioProtocolTest.cs index f59f972..6720cc4 100644 --- a/test/Microsoft.AspNetCore.Razor.Tools.Test/VisualStudioProtocolTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/VisualStudioProtocolTest.cs @@ -9,7 +9,7 @@ using Microsoft.AspNetCore.Razor.TagHelpers; using Newtonsoft.Json; using Xunit; -namespace Microsoft.AspNetCore.Razor.Tools +namespace Microsoft.AspNetCore.Razor.Design { public class VisualStudioProtocolTest { diff --git a/test/Microsoft.AspNetCore.Razor.Tools.Test/project.json b/test/Microsoft.AspNetCore.Razor.Design.Test/project.json similarity index 100% rename from test/Microsoft.AspNetCore.Razor.Tools.Test/project.json rename to test/Microsoft.AspNetCore.Razor.Design.Test/project.json diff --git a/test/Microsoft.AspNetCore.Razor.Tools.Test/Microsoft.AspNetCore.Razor.Tools.Test.xproj b/test/Microsoft.AspNetCore.Razor.Tools.Test/Microsoft.AspNetCore.Razor.Tools.Test.xproj deleted file mode 100644 index faf8f85..0000000 --- a/test/Microsoft.AspNetCore.Razor.Tools.Test/Microsoft.AspNetCore.Razor.Tools.Test.xproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - ab04d3ba-0a35-4502-ad4f-e8d1b38a6e5b - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\ - - - 2.0 - 3845 - - - - - - \ No newline at end of file