This commit is contained in:
neuecc 2019-10-17 18:24:28 +09:00
Родитель c7b661cec0
Коммит 15fbe13fcc
5 изменённых файлов: 124 добавлений и 1 удалений

Просмотреть файл

@ -79,6 +79,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MessagePack.GeneratorCore",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MessagePack.Generator", "src\MessagePack.Generator\MessagePack.Generator.csproj", "{32C91908-5CAD-4C95-B240-ACBBACAC9476}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MessagePack.MSBuild.Tasks", "src\MessagePack.MSBuild.Tasks\MessagePack.MSBuild.Tasks.csproj", "{8DB135F5-A6FE-44E4-9853-7B48ED21F21B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -173,6 +175,10 @@ Global
{32C91908-5CAD-4C95-B240-ACBBACAC9476}.Debug|Any CPU.Build.0 = Debug|Any CPU
{32C91908-5CAD-4C95-B240-ACBBACAC9476}.Release|Any CPU.ActiveCfg = Release|Any CPU
{32C91908-5CAD-4C95-B240-ACBBACAC9476}.Release|Any CPU.Build.0 = Release|Any CPU
{8DB135F5-A6FE-44E4-9853-7B48ED21F21B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8DB135F5-A6FE-44E4-9853-7B48ED21F21B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8DB135F5-A6FE-44E4-9853-7B48ED21F21B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8DB135F5-A6FE-44E4-9853-7B48ED21F21B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -200,6 +206,7 @@ Global
{8D9FD130-7905-47D8-A25C-7FDEE28EA0E8} = {19FE674A-AC94-4E7E-B24C-2285D1D04CDE}
{9962132D-A271-4E68-ACC1-18FA93462552} = {86309CF6-0054-4CE3-BFD3-CA0AA7DB17BC}
{32C91908-5CAD-4C95-B240-ACBBACAC9476} = {86309CF6-0054-4CE3-BFD3-CA0AA7DB17BC}
{8DB135F5-A6FE-44E4-9853-7B48ED21F21B} = {86309CF6-0054-4CE3-BFD3-CA0AA7DB17BC}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B3911209-2DBF-47F8-98F6-BBC0EDFE63DE}

Просмотреть файл

@ -3,6 +3,15 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
<LangVersion>latest</LangVersion>
<PackAsTool>true</PackAsTool>
<ToolCommandName>dotnet-mpc</ToolCommandName>
<!-- NuGet Info -->
<Title>MessagePack Code Generator</Title>
<Description>MessagePack standalone code generator.</Description>
<PackageTags>MsgPack;MessagePack;Serialization;Formatter;Serializer;Unity;Xamarin</PackageTags>
<AssemblyName>MessagePack.Generator</AssemblyName>
</PropertyGroup>
<ItemGroup>
@ -13,4 +22,4 @@
<ProjectReference Include="..\MessagePack.GeneratorCore\MessagePack.GeneratorCore.csproj" />
</ItemGroup>
</Project>
</Project>

Просмотреть файл

@ -0,0 +1,49 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>latest</LangVersion>
<!-- NuGet Packages for build task. -->
<NoPackageAnalysis>true</NoPackageAnalysis>
<BuildOutputTargetFolder>tasks</BuildOutputTargetFolder>
<!-- SKD depenencies local copy. -->
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<!-- NuGet Info -->
<IsPackable>true</IsPackable>
<Title>MessagePack CodeGenerator Tasks</Title>
<Description>MSBuild Tasks of MessagePack for C#.</Description>
<PackageTags>MsgPack;MessagePack;Serialization;Formatter;Serializer;Unity;Xamarin</PackageTags>
<AssemblyName>MessagePack.MSBuild.Tasks</AssemblyName>
</PropertyGroup>
<ItemGroup>
<!-- NuGet Tasks path. -->
<Content Include="build\MessagePack.MSBuild.Tasks.props" PackagePath="build\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Build.Framework" Version="16.0.461" />
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="16.0.461" />
<PackageReference Update="@(PackageReference)" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MessagePack.GeneratorCore\MessagePack.GeneratorCore.csproj" PrivateAssets="all" />
</ItemGroup>
<!--
The include needs to happen after output has been copied to build output folder
but before NuGet generates a nuspec. See https://github.com/NuGet/Home/issues/4704.
-->
<Target Name="PackTaskDependencies" BeforeTargets="GenerateNuspec">
<ItemGroup>
<_PackageFiles Include="$(OutDir)\**\*.dll" Exclude="$(OutDir)$(TargetFileName)">
<PackagePath>tasks\netstandard2.0\%(RecursiveDir)</PackagePath>
<Visible>false</Visible>
<BuildAction>Content</BuildAction>
</_PackageFiles>
</ItemGroup>
</Target>
</Project>

Просмотреть файл

@ -0,0 +1,49 @@
using System;
using System.Threading;
using MessagePackCompiler;
using Microsoft.Build.Framework;
namespace MessagePack.MSBuild.Tasks
{
public class MessagePackGenerator : Microsoft.Build.Utilities.Task
{
[Required]
public string Input { get; set; }
[Required]
public string Output { get; set; }
public string ConditionalSymbol { get; set; }
public string ResolverName { get; set; }
public string Namespace { get; set; }
public bool UseMapMode { get; set; }
public string MultipleIfDirectiveOutputSymbols { get; set; }
public override bool Execute()
{
try
{
new CodeGenerator(x => this.Log.LogMessage(x), CancellationToken.None)
.GenerateFileAsync(
Input,
Output,
ConditionalSymbol,
ResolverName ?? "GeneratedResolver",
Namespace ?? "MessagePack",
UseMapMode,
MultipleIfDirectiveOutputSymbols
)
.GetAwaiter().GetResult();
}
catch (Exception ex)
{
this.Log.LogErrorFromException(ex, true);
return false;
}
return true;
}
}
}

Просмотреть файл

@ -0,0 +1,9 @@
<Project TreatAsLocalProperty="TaskFolder;TaskAssembly">
<PropertyGroup>
<TaskFolder>netstandard2.0</TaskFolder>
<TaskAssembly>$(MSBuildThisFileDirectory)..\tasks\$(TaskFolder)\MessagePack.MSBuild.Tasks.dll</TaskAssembly>
</PropertyGroup>
<UsingTask TaskName="MessagePack.MSBuild.Tasks.MessagePackGenerator" AssemblyFile="$(TaskAssembly)" />
</Project>