Skip to content

Commit 2e1bd09

Browse files
committed
Fix(build): Correct MSBuild targets for cross-platform compatibility
1 parent 922937d commit 2e1bd09

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

src/SharpAssert/SharpLambdaRewriteTask.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ public class SharpLambdaRewriteTask : Microsoft.Build.Utilities.Task
3131
[Output]
3232
public ITaskItem[] GeneratedFiles { get; set; } = [];
3333

34+
[Output]
35+
public ITaskItem[] ProcessedSourceFiles { get; set; } = [];
36+
3437
public override bool Execute()
3538
{
3639
try
@@ -55,6 +58,7 @@ bool ExecuteInternal()
5558
EnsureDirectoryExists(OutputDir);
5659

5760
var generatedFiles = new List<ITaskItem>();
61+
var processedSourceFiles = new List<ITaskItem>();
5862
var fileMappings = new Dictionary<string, string>();
5963
var processedCount = 0;
6064
var skippedCount = 0;
@@ -65,11 +69,15 @@ bool ExecuteInternal()
6569
var sourcePath = sourceItem.ItemSpec;
6670
var result = ProcessSourceFile(sourcePath);
6771

72+
if (result.Status == ProcessingStatus.Processed)
73+
processedSourceFiles.Add(sourceItem);
74+
6875
UpdateCounters(result.Status, ref processedCount, ref skippedCount, ref generatedFilesCount);
6976
AddToGeneratedFiles(result, sourcePath, generatedFiles, fileMappings);
7077
}
7178

7279
GeneratedFiles = generatedFiles.ToArray();
80+
ProcessedSourceFiles = processedSourceFiles.ToArray();
7381

7482
Log.LogMessage(MessageImportance.Normal, $"SharpAssert: Processed {processedCount} files with rewrites");
7583
LogDiagnostics($"Generated {GeneratedFiles.Length} output files for MSBuild tracking");

src/SharpAssert/build/SharpAssert.targets

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<ItemGroup>
1818
<_SharpInput Include="@(Compile)" />
1919
<_SharpNonSourceFiles Include="@(Compile)" Condition="$([System.String]::Copy('%(Identity)').Contains('Microsoft.NET.Test.Sdk.Program.cs')) or $([System.String]::Copy('%(Identity)').EndsWith('.AssemblyInfo.cs')) or $([System.String]::Copy('%(Identity)').EndsWith('.AssemblyAttributes.cs')) or $([System.String]::Copy('%(Identity)').EndsWith('.GlobalUsings.g.cs'))" />
20-
<_SharpSourceFiles Include="@(Compile)" Exclude="@(_SharpNonSourceFiles)" />
20+
<_SharpSourceFiles Include="**/*.cs" Exclude="**/bin/**/*.cs;**/obj/**/*.cs;$(IntermediateOutputPath)/**/*.cs" />
2121
</ItemGroup>
2222

2323
<Target Name="SharpLambdaRewrite" BeforeTargets="CoreCompile"
@@ -36,20 +36,12 @@
3636
OutputDir="$(IntermediateOutputPath)SharpRewritten"
3737
LangVersion="$(LangVersion)"
3838
UsePowerAssert="$(SharpAssertUsePowerAssert)"
39-
UsePowerAssertForUnsupported="$(SharpAssertUsePowerAssertForUnsupported)" />
39+
UsePowerAssertForUnsupported="$(SharpAssertUsePowerAssertForUnsupported)">
40+
<Output TaskParameter="GeneratedFiles" ItemName="_SharpRewrittenFiles" />
41+
<Output TaskParameter="ProcessedSourceFiles" ItemName="_SharpProcessedSources" />
42+
</SharpLambdaRewriteTask>
4043

4144
<ItemGroup>
42-
<!-- Track rewritten files for potential cleanup -->
43-
<_SharpRewrittenFiles Include="$(IntermediateOutputPath)SharpRewritten\**\*.sharp.g.cs" />
44-
45-
<!-- Identify which source files were actually rewritten -->
46-
<_SharpProcessedSources Include="@(_SharpSourceFiles)"
47-
Condition="Exists('$(IntermediateOutputPath)SharpRewritten\%(RecursiveDir)%(Filename)%(Extension).sharp.g.cs')" />
48-
49-
<!-- Find source files that weren't processed (no Assert calls) -->
50-
<_SharpUnprocessedSources Include="@(_SharpSourceFiles)"
51-
Exclude="@(_SharpProcessedSources)" />
52-
5345
<!-- Only remove files that were actually rewritten -->
5446
<Compile Remove="@(_SharpProcessedSources)" />
5547

0 commit comments

Comments
 (0)