Skip to content

Commit

Permalink
Merge pull request #1528 from AArnott/fix1526
Browse files Browse the repository at this point in the history
Add incremental build support to MessagePack.MSBuild.Tasks
  • Loading branch information
AArnott committed Nov 19, 2022
2 parents 3bc35e3 + 0c41ccb commit e9cdd76
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
7 changes: 1 addition & 6 deletions src/MessagePack.MSBuild.Tasks/MessagePackGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class MessagePackGenerator : Microsoft.Build.Utilities.Task, ICancelableT
public ITaskItem[] Compile { get; set; } = null!;

[Required]
public string IntermediateOutputPath { get; set; } = null!;
public string GeneratedOutputPath { get; set; } = null!;

[Required]
public ITaskItem[] ReferencePath { get; set; } = null!;
Expand All @@ -44,9 +44,6 @@ public class MessagePackGenerator : Microsoft.Build.Utilities.Task, ICancelableT

public string[]? ExternalIgnoreTypeNames { get; set; }

[Output]
public string? GeneratedOutputPath { get; set; }

internal CancellationToken CancellationToken => this.cts.Token;

public void Cancel() => this.cts.Cancel();
Expand All @@ -59,8 +56,6 @@ public override bool Execute()
return false;
}

this.GeneratedOutputPath = Path.Combine(this.IntermediateOutputPath, GeneratedFileName);

try
{
var compilation = this.CreateCompilation();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
<Project>
<PropertyGroup>
<GeneratedMessagePackFile Condition="'$(GeneratedMessagePackFile)'==''">$(IntermediateOutputPath)mpc_generated.cs</GeneratedMessagePackFile>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(GeneratedMessagePackFile)" />
<FileWrites Include="$(GeneratedMessagePackFile)" />
</ItemGroup>

<UsingTask TaskName="MessagePackGenerator" AssemblyFile="MessagePack.MSBuild.Tasks.dll" />

<Target Name="GenerateMessagePackResolver"
BeforeTargets="CoreCompile"
DependsOnTargets="ResolveReferences">
DependsOnTargets="ResolveReferences"
Inputs="@(Compile)"
Outputs="$(GeneratedMessagePackFile)">

<MessagePackGenerator
Compile="@(Compile)"
IntermediateOutputPath="$(IntermediateOutputPath)"
GeneratedOutputPath="$(GeneratedMessagePackFile)"
ReferencePath="@(ReferencePath)"
DefineConstants="$(DefineConstants)"
Namespace="$(MessagePackGeneratedResolverNamespace)"
ResolverName="$(MessagePackGeneratedResolverName)"
UseMapMode="$(MessagePackGeneratedUsesMapMode)"
>
<Output TaskParameter="GeneratedOutputPath" ItemName="Compile" />
<Output TaskParameter="GeneratedOutputPath" ItemName="FileWrites" />
</MessagePackGenerator>
/>
</Target>
</Project>

0 comments on commit e9cdd76

Please sign in to comment.