diff --git a/CompiledHandlebars.Cli2/CompiledHandlebars.Core.Cli.csproj b/CompiledHandlebars.Cli2/CompiledHandlebars.Core.Cli.csproj index 7de9b2f..11d993d 100644 --- a/CompiledHandlebars.Cli2/CompiledHandlebars.Core.Cli.csproj +++ b/CompiledHandlebars.Cli2/CompiledHandlebars.Core.Cli.csproj @@ -11,14 +11,14 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + diff --git a/CompiledHandlebars.Cli2/Program.cs b/CompiledHandlebars.Cli2/Program.cs index c81d99b..113ed87 100644 --- a/CompiledHandlebars.Cli2/Program.cs +++ b/CompiledHandlebars.Cli2/Program.cs @@ -10,6 +10,8 @@ using System.Linq; using Buildalyzer.Workspaces; using Buildalyzer; +using Buildalyzer.Environment; +using Microsoft.Extensions.Logging; namespace CompiledHandlebars.Core.Cli { @@ -149,6 +151,9 @@ private static void PrintUnknownExtension(string ext) private static void CompileProject(CompilerOptions options) { Console.WriteLine($"Loading project '{options.ProjectFile}'..."); + //string x = Console.ReadLine(); + Stopwatch sw = new Stopwatch(); + sw.Start(); var properties = new Dictionary() { { "AdditionalFileItemNames", "none" } }; @@ -158,18 +163,33 @@ private static void CompileProject(CompilerOptions options) List handlebarsFiles; if (options.NetCoreProject) { + StringWriter log = new StringWriter(); try { - AnalyzerManager manager = new AnalyzerManager(); + AnalyzerManagerOptions analyzerOptions = new AnalyzerManagerOptions + { + LogWriter = log + }; + AnalyzerManager manager = new AnalyzerManager(analyzerOptions); + IProjectAnalyzer analyzer = manager.GetProject(options.ProjectFile); + workspace = analyzer.GetWorkspace(); + //ILogger logger = manager.LoggerFactory?.CreateLogger(); + //workspace = new AdhocWorkspace(); + //workspace.WorkspaceChanged += (sender, args) => logger?.LogDebug($"Workspace changed: {args.Kind.ToString()}{System.Environment.NewLine}"); + //workspace.WorkspaceFailed += (sender, args) => logger?.LogError($"Workspace failed: {args.Diagnostic}{System.Environment.NewLine}"); + //analyzer.Build(new EnvironmentOptions() { Restore = true }).FirstOrDefault().AddToWorkspace(workspace); + project = workspace.CurrentSolution.Projects.ElementAt(0); - Console.WriteLine("Ok!"); + sw.Stop(); + Console.WriteLine($"Ok! {sw.Elapsed}"); + Console.WriteLine($"Log: {log.ToString()}"); handlebarsFiles = new DirectoryInfo(Path.GetDirectoryName(Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), options.ProjectFile)))).GetFiles("*.hbs", SearchOption.AllDirectories).Where(f => ShouldCompileFile(f.FullName, options)).Select(f => f.FullName).ToList(); } catch (Exception ex) { - Console.WriteLine($"Following errors occured: {Environment.NewLine}{ex}"); + Console.WriteLine($"Following errors occured: {Environment.NewLine}{ex} - {log.ToString()}"); throw; } } @@ -274,7 +294,7 @@ private static void CompileSolution(CompilerOptions options) if (handlebarsFiles.Count > 0) anyHbsFilesFound = true; } - + if (handlebarsFiles.Any()) { workspace = CompileHandlebarsFiles(project, workspace, handlebarsFiles, options); @@ -419,7 +439,7 @@ private static Workspace CompileHandlebarsFiles(Project project, Workspace works private static void PrintError(HandlebarsException error) { - Console.Error.WriteLine($"Compilation failed: {error.Message}"); + Console.Error.WriteLine($"*** Compilation failed: {error.Message}"); } /// diff --git a/CompiledHandlebars.Cli2/Properties/PublishProfiles/FolderProfile.pubxml b/CompiledHandlebars.Cli2/Properties/PublishProfiles/FolderProfile.pubxml deleted file mode 100644 index 22dc206..0000000 --- a/CompiledHandlebars.Cli2/Properties/PublishProfiles/FolderProfile.pubxml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - Debug - x64 - D:\hbc - FileSystem - netcoreapp3.1 - linux-x64 - false - True - - \ No newline at end of file diff --git a/CompiledHandlebars.Cli2/Properties/PublishProfiles/linux.pubxml b/CompiledHandlebars.Cli2/Properties/PublishProfiles/linux.pubxml new file mode 100644 index 0000000..1b4d141 --- /dev/null +++ b/CompiledHandlebars.Cli2/Properties/PublishProfiles/linux.pubxml @@ -0,0 +1,18 @@ + + + + + Release + x64 + C:\D\hbc\linux + FileSystem + net7.0 + linux-x64 + false + false + + en + + \ No newline at end of file diff --git a/CompiledHandlebars.Cli2/Properties/PublishProfiles/windows.pubxml b/CompiledHandlebars.Cli2/Properties/PublishProfiles/windows.pubxml new file mode 100644 index 0000000..42ab987 --- /dev/null +++ b/CompiledHandlebars.Cli2/Properties/PublishProfiles/windows.pubxml @@ -0,0 +1,18 @@ + + + + + Release + Any CPU + C:\D\hbc\windows + FileSystem + net7.0 + win-x64 + false + false + true + en + + \ No newline at end of file diff --git a/CompiledHandlebars.Cli2/Properties/launchSettings.json b/CompiledHandlebars.Cli2/Properties/launchSettings.json index 6d1a1c9..eec448e 100644 --- a/CompiledHandlebars.Cli2/Properties/launchSettings.json +++ b/CompiledHandlebars.Cli2/Properties/launchSettings.json @@ -2,7 +2,12 @@ "profiles": { "CompiledHandlebars.Cli2": { "commandName": "Project", - "commandLineArgs": "-c -d -f -eC:\\dev\\sw.git\\StiftungWarentest.Website\\node_modules -eC:\\dev\\sw.git\\StiftungWarentest.Website\\assets C:\\dev\\sw.git\\StiftungWarentest.Website\\StiftungWarentest.Website.csproj" + "commandLineArgs": "-c -d -eC:\\dev\\Repos\\StiftungWarentest.Web\\StiftungWarentest.Website\\node_modules -eC:\\dev\\Repos\\StiftungWarentest.Web\\StiftungWarentest.Website\\assets C:\\dev\\Repos\\StiftungWarentest.Web\\StiftungWarentest.Website\\StiftungWarentest.Website.csproj" + }, + "WSL": { + "commandName": "WSL2", + "distributionName": "", + "commandLineArgs": "CompiledHandlebars.Core.Cli.dll -c -d -e/mnt/c/dev/Repos/StiftungWarentest.Web/StiftungWarentest.Website/node_modules -e/mnt/c/dev/Repos/StiftungWarentest.Web/StiftungWarentest.Website/assets /mnt/c/dev/Repos/StiftungWarentest.Web/StiftungWarentest.Website/StiftungWarentest.Website.csproj" } } } \ No newline at end of file diff --git a/CompiledHandlebars.sln b/CompiledHandlebars.sln index 43e3b8c..8ed7147 100644 --- a/CompiledHandlebars.sln +++ b/CompiledHandlebars.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30611.23 +# Visual Studio Version 17 +VisualStudioVersion = 17.4.33213.308 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CompiledHandlebars.Compiler", "Compiler\CompiledHandlebars.Compiler.csproj", "{55E767E0-44F0-4297-9A00-7211B424BE03}" EndProject @@ -19,14 +19,14 @@ Global Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {55E767E0-44F0-4297-9A00-7211B424BE03}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {55E767E0-44F0-4297-9A00-7211B424BE03}.Debug|Any CPU.Build.0 = Debug|Any CPU + {55E767E0-44F0-4297-9A00-7211B424BE03}.Debug|Any CPU.ActiveCfg = Debug|x64 + {55E767E0-44F0-4297-9A00-7211B424BE03}.Debug|Any CPU.Build.0 = Debug|x64 {55E767E0-44F0-4297-9A00-7211B424BE03}.Debug|x64.ActiveCfg = Debug|x64 {55E767E0-44F0-4297-9A00-7211B424BE03}.Debug|x64.Build.0 = Debug|x64 {55E767E0-44F0-4297-9A00-7211B424BE03}.Debug|x86.ActiveCfg = Debug|Any CPU {55E767E0-44F0-4297-9A00-7211B424BE03}.Debug|x86.Build.0 = Debug|Any CPU - {55E767E0-44F0-4297-9A00-7211B424BE03}.Release|Any CPU.ActiveCfg = Release|Any CPU - {55E767E0-44F0-4297-9A00-7211B424BE03}.Release|Any CPU.Build.0 = Release|Any CPU + {55E767E0-44F0-4297-9A00-7211B424BE03}.Release|Any CPU.ActiveCfg = Release|x64 + {55E767E0-44F0-4297-9A00-7211B424BE03}.Release|Any CPU.Build.0 = Release|x64 {55E767E0-44F0-4297-9A00-7211B424BE03}.Release|x64.ActiveCfg = Release|x64 {55E767E0-44F0-4297-9A00-7211B424BE03}.Release|x64.Build.0 = Release|x64 {55E767E0-44F0-4297-9A00-7211B424BE03}.Release|x86.ActiveCfg = Release|Any CPU @@ -39,8 +39,8 @@ Global {A3B28E61-F74A-4156-BD99-0FD46E475EDF}.Debug|x86.Build.0 = Debug|Any CPU {A3B28E61-F74A-4156-BD99-0FD46E475EDF}.Release|Any CPU.ActiveCfg = Release|Any CPU {A3B28E61-F74A-4156-BD99-0FD46E475EDF}.Release|Any CPU.Build.0 = Release|Any CPU - {A3B28E61-F74A-4156-BD99-0FD46E475EDF}.Release|x64.ActiveCfg = Release|Any CPU - {A3B28E61-F74A-4156-BD99-0FD46E475EDF}.Release|x64.Build.0 = Release|Any CPU + {A3B28E61-F74A-4156-BD99-0FD46E475EDF}.Release|x64.ActiveCfg = Release|x64 + {A3B28E61-F74A-4156-BD99-0FD46E475EDF}.Release|x64.Build.0 = Release|x64 {A3B28E61-F74A-4156-BD99-0FD46E475EDF}.Release|x86.ActiveCfg = Release|Any CPU {A3B28E61-F74A-4156-BD99-0FD46E475EDF}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection diff --git a/Compiler/CompiledHandlebars.Compiler.csproj b/Compiler/CompiledHandlebars.Compiler.csproj index 5321713..45d39f4 100644 --- a/Compiler/CompiledHandlebars.Compiler.csproj +++ b/Compiler/CompiledHandlebars.Compiler.csproj @@ -24,17 +24,23 @@ true true + + portable + + + portable + - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + diff --git a/Compiler/Introspection/RoslynIntrospector.cs b/Compiler/Introspection/RoslynIntrospector.cs index 6f975fe..f39538c 100644 --- a/Compiler/Introspection/RoslynIntrospector.cs +++ b/Compiler/Introspection/RoslynIntrospector.cs @@ -68,7 +68,7 @@ private Compilation GetCompilationForProject(Project proj) Compilation comp; if (proj.TryGetCompilation(out comp)) return comp; - else return proj.GetCompilationAsync().Result; + else return proj.GetCompilationAsync().GetAwaiter().GetResult(); } public INamedTypeSymbol GetTypeSymbol(string fullTypeName)