MSBuild
This commit is contained in:
parent
16dda45611
commit
07fa774303
5 changed files with 143 additions and 2 deletions
30
.vscode/launch.json
vendored
Normal file
30
.vscode/launch.json
vendored
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
{
|
||||||
|
// Use IntelliSense to learn about possible attributes.
|
||||||
|
// Hover to view descriptions of existing attributes.
|
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": ".NET Core Launch (console)",
|
||||||
|
"type": "coreclr",
|
||||||
|
"request": "launch",
|
||||||
|
"preLaunchTask": "build",
|
||||||
|
"program": "${workspaceFolder}/src/Nyanbyte.Dotconf/bin/Debug/net7.0/Nyanbyte.Dotconf.dll",
|
||||||
|
"args": ["/home/nya/Dev/csharp/dotconf/"],
|
||||||
|
"cwd": "${workspaceFolder}/src/Nyanbyte.Dotconf",
|
||||||
|
"console": "internalConsole",
|
||||||
|
"pipeTransport": {
|
||||||
|
"pipeCwd": "${workspaceFolder}",
|
||||||
|
"pipeProgram": "/usr/bin/bash",
|
||||||
|
"pipeArgs": ["-c"],
|
||||||
|
"debuggerPath": "/usr/bin/netcoredbg"
|
||||||
|
},
|
||||||
|
"stopAtEntry": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": ".NET Core Attach",
|
||||||
|
"type": "coreclr",
|
||||||
|
"request": "attach"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
41
.vscode/tasks.json
vendored
Normal file
41
.vscode/tasks.json
vendored
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
{
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"label": "build",
|
||||||
|
"command": "dotnet",
|
||||||
|
"type": "process",
|
||||||
|
"args": [
|
||||||
|
"build",
|
||||||
|
"${workspaceFolder}/DotConf.sln",
|
||||||
|
"/property:GenerateFullPaths=true",
|
||||||
|
"/consoleloggerparameters:NoSummary"
|
||||||
|
],
|
||||||
|
"problemMatcher": "$msCompile"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "publish",
|
||||||
|
"command": "dotnet",
|
||||||
|
"type": "process",
|
||||||
|
"args": [
|
||||||
|
"publish",
|
||||||
|
"${workspaceFolder}/DotConf.sln",
|
||||||
|
"/property:GenerateFullPaths=true",
|
||||||
|
"/consoleloggerparameters:NoSummary"
|
||||||
|
],
|
||||||
|
"problemMatcher": "$msCompile"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "watch",
|
||||||
|
"command": "dotnet",
|
||||||
|
"type": "process",
|
||||||
|
"args": [
|
||||||
|
"watch",
|
||||||
|
"run",
|
||||||
|
"--project",
|
||||||
|
"${workspaceFolder}/DotConf.sln"
|
||||||
|
],
|
||||||
|
"problemMatcher": "$msCompile"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
12
src/Nyanbyte.Dotconf/Cli.cs
Normal file
12
src/Nyanbyte.Dotconf/Cli.cs
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.CommandLine;
|
||||||
|
|
||||||
|
namespace Nyanbyte.Dotconf;
|
||||||
|
|
||||||
|
public class Cli
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
|
@ -7,4 +7,11 @@
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Build" Version="17.7.2" ExcludeAssets="runtime" />
|
||||||
|
<PackageReference Include="Microsoft.Build.Locator" Version="1.6.10" />
|
||||||
|
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="17.7.2" ExcludeAssets="runtime" />
|
||||||
|
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -1,2 +1,53 @@
|
||||||
// See https://aka.ms/new-console-template for more information
|
using Microsoft.Build.Construction;
|
||||||
Console.WriteLine("Hello, World!");
|
using Microsoft.Build.Definition;
|
||||||
|
using Microsoft.Build.Evaluation;
|
||||||
|
using Microsoft.Build.Locator;
|
||||||
|
|
||||||
|
namespace Nyanbyte.Dotconf;
|
||||||
|
|
||||||
|
public class Program
|
||||||
|
{
|
||||||
|
private static void Main(string[] args)
|
||||||
|
{
|
||||||
|
Console.WriteLine("meow~");
|
||||||
|
|
||||||
|
var instance = MSBuildLocator.QueryVisualStudioInstances(VisualStudioInstanceQueryOptions.Default).First();
|
||||||
|
|
||||||
|
foreach (var inst in MSBuildLocator.QueryVisualStudioInstances(VisualStudioInstanceQueryOptions.Default))
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Found {inst.Name} {inst.Version}");
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine($"Instance ver: {instance.Version}");
|
||||||
|
|
||||||
|
MSBuildLocator.RegisterInstance(instance);
|
||||||
|
|
||||||
|
Build(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Build(string[] args)
|
||||||
|
{
|
||||||
|
var solution = Directory.EnumerateFiles(Directory.GetCurrentDirectory()).FirstOrDefault(x => x.EndsWith(".sln"));
|
||||||
|
if (solution is null)
|
||||||
|
{
|
||||||
|
if (args.Length > 0)
|
||||||
|
{
|
||||||
|
solution = Directory.EnumerateFiles(args[0]).FirstOrDefault(x => x.EndsWith(".sln"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (solution is null)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine("Solution file not found.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var sln = SolutionFile.Parse(solution);
|
||||||
|
|
||||||
|
var projects = sln.ProjectsInOrder.Where(p => File.Exists(p.AbsolutePath)).Select(p => new Project(p.AbsolutePath)).ToList();
|
||||||
|
foreach (var proj in projects)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Building {proj.DirectoryPath}");
|
||||||
|
proj.Build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue