fix weird dll copying issue

This commit is contained in:
Matt Parker
2025-08-13 18:03:45 +10:00
parent eea4a41d7e
commit f37f70e2ad
4 changed files with 21 additions and 14 deletions

View File

@@ -23,17 +23,17 @@ public static class RoslynTest
foreach (var document in project.Documents)
{
Console.WriteLine($"Document: {document.Name}");
var compilation = await project.GetCompilationAsync();
Guard.Against.Null(compilation, nameof(compilation));
// Get diagnostics (built-in or custom analyzers)
var diagnostics = compilation.GetDiagnostics();
foreach (var diagnostic in diagnostics)
{
Console.WriteLine(diagnostic);
// Optionally run CodeFixProviders here
}
// var compilation = await project.GetCompilationAsync();
// Guard.Against.Null(compilation, nameof(compilation));
//
// // Get diagnostics (built-in or custom analyzers)
// var diagnostics = compilation.GetDiagnostics();
//
// foreach (var diagnostic in diagnostics)
// {
// Console.WriteLine(diagnostic);
// // Optionally run CodeFixProviders here
// }
// var syntaxTree = await document.GetSyntaxTreeAsync();
// var root = await syntaxTree!.GetRootAsync();
// var classifiedSpans = await Classifier.GetClassifiedSpansAsync(document, root.FullSpan);

View File

@@ -53,6 +53,10 @@ public class BuildService
var buildResult = await BuildManager.DefaultBuildManager.BuildAsync(buildParameters, buildRequest, cancellationToken).ConfigureAwait(false);
timer.Stop();
Console.WriteLine($"Build result: {buildResult.OverallResult} in {timer.ElapsedMilliseconds}ms");
if (buildResult.OverallResult != BuildResultCode.Success)
{
Console.WriteLine($"{buildResult.Exception}");
}
}
private static string[] TargetsToBuild(BuildType buildType)

View File

@@ -0,0 +1,2 @@
throw new InvalidOperationException("This project is not executable - Exe OutputType is used to work around a build issue.");

View File

@@ -3,11 +3,12 @@
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<OutputType>Exe</OutputType> <!-- Exe output type is required for obscure Microsoft.CodeAnalysis.Workspaces.MSBuild dll copying reasons -->
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<!-- If any Microsoft.Build.dll ends up in the output, it will be prioritised for loading by MSBuild Nodes -->
<!-- If any Microsoft.Build.*.dll (Excluding Locator) ends up in the output, it will be prioritised for loading by MSBuild Nodes -->
<PackageReference Include="Ardalis.GuardClauses" Version="5.0.0" />
<PackageReference Include="AsyncReadProcess" Version="1.0.0-preview9" />
<PackageReference Include="Microsoft.Build" Version="17.14.8" ExcludeAssets="runtime" />
@@ -15,8 +16,8 @@
<PackageReference Include="Microsoft.Build.Locator" Version="1.9.1" />
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="17.14.8" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="17.14.8" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.14.0" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.14.0" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.14.0" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.14.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.VisualStudio.SolutionPersistence" Version="1.0.52" />
<PackageReference Include="NuGet.Protocol" Version="6.14.0" />
</ItemGroup>