-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6b28573
commit 76af075
Showing
16 changed files
with
193 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,9 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard1.3</TargetFramework> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<RootNamespace>Hagar</RootNamespace> | ||
<PackageDescription>Fast, flexible, and version-tolerant serializer for .NET</PackageDescription> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Update="SourceLink.Create.GitHub" Version="2.8.3" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace Hagar.CodeGenerator.MSBuild.Tasks | ||
{ | ||
/// <summary> | ||
/// Utilities for finding the "dotnet.exe" file from the currently running .NET Core application | ||
/// </summary> | ||
internal static class DotNetMuxer | ||
{ | ||
private const string MuxerName = "dotnet"; | ||
|
||
static DotNetMuxer() | ||
{ | ||
MuxerPath = TryFindMuxerPath(); | ||
} | ||
|
||
/// <summary> | ||
/// The full filepath to the .NET Core muxer. | ||
/// </summary> | ||
public static string MuxerPath { get; } | ||
|
||
/// <summary> | ||
/// Finds the full filepath to the .NET Core muxer, | ||
/// or returns a string containing the default name of the .NET Core muxer ('dotnet'). | ||
/// </summary> | ||
/// <returns>The path or a string named 'dotnet'.</returns> | ||
public static string MuxerPathOrDefault() | ||
=> MuxerPath ?? MuxerName; | ||
|
||
private static string TryFindMuxerPath() | ||
{ | ||
var fileName = MuxerName; | ||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) | ||
{ | ||
fileName += ".exe"; | ||
} | ||
|
||
var mainModule = Process.GetCurrentProcess().MainModule; | ||
if (!string.IsNullOrEmpty(mainModule?.FileName) | ||
&& Path.GetFileName(mainModule.FileName).Equals(fileName, StringComparison.OrdinalIgnoreCase)) | ||
{ | ||
return mainModule.FileName; | ||
} | ||
|
||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Microsoft.Build.Framework; | ||
using MSBuildTask = Microsoft.Build.Utilities.Task; | ||
|
||
namespace Hagar.CodeGenerator.MSBuild.Tasks | ||
{ | ||
public class GetDotNetHost : MSBuildTask | ||
{ | ||
[Output] | ||
public string DotNetHost { get; set; } | ||
|
||
public override bool Execute() | ||
{ | ||
this.DotNetHost = TryFindDotNetExePath(); | ||
return true; | ||
} | ||
|
||
private static string TryFindDotNetExePath() => DotNetMuxer.MuxerPathOrDefault(); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/Hagar.CodeGenerator.MSBuild.Tasks/Hagar.CodeGenerator.MSBuild.Tasks.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="15.5.180" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.