Build sln on load
This commit is contained in:
@@ -9,6 +9,8 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Build" Version="17.14.8" ExcludeAssets="runtime" />
|
||||
<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" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.14.0" />
|
||||
<PackageReference Include="NuGet.Protocol" Version="6.14.0" />
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
private async Task PickSolution()
|
||||
{
|
||||
var files = await PhotinoBlazorApp.MainWindow.ShowOpenFileAsync("Choose Solution File", filters: [("Solution File", [".sln"])]);
|
||||
var files = await PhotinoBlazorApp.MainWindow.ShowOpenFileAsync("Choose Solution File", filters: [("Solution File", [".sln", ".slnx"])]);
|
||||
var slnFile = files.SingleOrDefault();
|
||||
_solutionFilePath = slnFile;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
@inherits LayoutComponentBase
|
||||
@using Microsoft.Build.Construction
|
||||
@using Microsoft.Build.Definition
|
||||
@using Microsoft.Build.Execution
|
||||
@using Microsoft.Build.Framework
|
||||
@using Microsoft.Build.Logging
|
||||
@using SharpIDE.Application.Features.SolutionDiscovery
|
||||
@inherits LayoutComponentBase
|
||||
|
||||
@inject IDialogService DialogService
|
||||
|
||||
@@ -42,5 +48,29 @@
|
||||
if (result.Canceled) throw new OperationCanceledException("Dialog was canceled");
|
||||
var solutionFilePath = (string)result.Data!;
|
||||
_solutionFilePath = solutionFilePath;
|
||||
|
||||
var buildParameters = new BuildParameters
|
||||
{
|
||||
Loggers =
|
||||
[
|
||||
//new BinaryLogger { Parameters = "msbuild.binlog" },
|
||||
new ConsoleLogger(LoggerVerbosity.Quiet),
|
||||
],
|
||||
};
|
||||
// var solutionFile = GetNodesInSolution.ParseSolutionFileFromPath(_solutionFilePath);
|
||||
// ArgumentNullException.ThrowIfNull(solutionFile);
|
||||
// var projects = GetNodesInSolution.GetCSharpProjectObjectsFromSolutionFile(solutionFile);
|
||||
// var projectRoot = projects.First();
|
||||
// var buildRequest = new BuildRequestData(
|
||||
// ProjectInstance.FromProjectRootElement(projectRoot, new ProjectOptions()),
|
||||
// targetsToBuild: ["Restore", "Build"]);
|
||||
var buildRequest = new BuildRequestData(projectFullPath : _solutionFilePath,
|
||||
globalProperties: new Dictionary<string, string?>(),
|
||||
toolsVersion: null,
|
||||
targetsToBuild: ["Restore", "Build"],
|
||||
hostServices: null,
|
||||
flags: BuildRequestDataFlags.None);
|
||||
var result2 = BuildManager.DefaultBuildManager.Build(buildParameters, buildRequest);
|
||||
Console.WriteLine(result2.OverallResult);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,8 @@ public class Program
|
||||
};
|
||||
|
||||
var instance = MSBuildLocator.QueryVisualStudioInstances().OrderByDescending(instance => instance.Version).First();
|
||||
MSBuildLocator.RegisterInstance(instance);
|
||||
//MSBuildLocator.RegisterInstance(instance);
|
||||
MSBuildLocator.RegisterDefaults();
|
||||
|
||||
app.Run();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user