Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions CompiledHandlebars.Cli2/CompiledHandlebars.Core.Cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
<PackageReference Include="Buildalyzer" Version="5.0.0" />
<PackageReference Include="Buildalyzer.Logger" Version="5.0.0" />
<PackageReference Include="Buildalyzer.Workspaces" Version="5.0.0" />
<PackageReference Include="Microsoft.Build" Version="17.4.0" />
<PackageReference Include="Microsoft.CodeAnalysis" Version="4.4.0" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.3">
<PackageReference Include="Microsoft.Build" Version="17.5.0" />
<PackageReference Include="Microsoft.CodeAnalysis" Version="4.5.0" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.4.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.4.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.5.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.5.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="System.Diagnostics.Debug" Version="4.3.0" />
<PackageReference Include="System.IO.FileSystem.Primitives" Version="4.3.0" />
Expand Down
30 changes: 25 additions & 5 deletions CompiledHandlebars.Cli2/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
using System.Linq;
using Buildalyzer.Workspaces;
using Buildalyzer;
using Buildalyzer.Environment;
using Microsoft.Extensions.Logging;

namespace CompiledHandlebars.Core.Cli
{
Expand Down Expand Up @@ -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<string, string>() {
{ "AdditionalFileItemNames", "none" }
};
Expand All @@ -158,18 +163,33 @@ private static void CompileProject(CompilerOptions options)
List<string> 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<AdhocWorkspace>();
//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;
}
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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}");
}

/// <summary>
Expand Down

This file was deleted.

18 changes: 18 additions & 0 deletions CompiledHandlebars.Cli2/Properties/PublishProfiles/linux.pubxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>x64</Platform>
<PublishDir>C:\D\hbc\linux</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<TargetFramework>net7.0</TargetFramework>
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
<SelfContained>false</SelfContained>
<PublishSingleFile>false</PublishSingleFile>
<!-- false: analyser lädt sonst nicht ;-( -->
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
</PropertyGroup>
</Project>
18 changes: 18 additions & 0 deletions CompiledHandlebars.Cli2/Properties/PublishProfiles/windows.pubxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>C:\D\hbc\windows</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<TargetFramework>net7.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>false</SelfContained>
<PublishSingleFile>false</PublishSingleFile><!-- analyser lädt sonst nicht ;-( -->
<PublishReadyToRun>true</PublishReadyToRun>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
</PropertyGroup>
</Project>
7 changes: 6 additions & 1 deletion CompiledHandlebars.Cli2/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
16 changes: 8 additions & 8 deletions CompiledHandlebars.sln
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
14 changes: 10 additions & 4 deletions Compiler/CompiledHandlebars.Compiler.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,23 @@
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<DebugType>portable</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<DebugType>portable</DebugType>
</PropertyGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis" Version="4.4.0" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.3">
<PackageReference Include="Microsoft.CodeAnalysis" Version="4.5.0" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.4.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.4.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.5.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.5.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Pegasus" Version="4.1.0" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Compiler/Introspection/RoslynIntrospector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down