Skip to content

Commit 69977fa

Browse files
CopilotSoar360
andcommitted
Address code review feedback
- Changed BuildAction from Content to None for MSBuild task assemblies - Simplified property assignment using MSBuild ValueOrDefault function - Removed redundant CopyToOutputDirectory setting from test scenario - Added README to test-scenario explaining the feature Co-authored-by: Soar360 <[email protected]>
1 parent b9e5c2d commit 69977fa

File tree

4 files changed

+54
-6
lines changed

4 files changed

+54
-6
lines changed

LuYao.ResourcePacker.MSBuild/LuYao.ResourcePacker.MSBuild.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@
3030
<_PackageFiles Include="$(OutputPath)LuYao.ResourcePacker.MSBuild.dll">
3131
<PackagePath>tasks/$(TargetFramework)</PackagePath>
3232
<Visible>false</Visible>
33-
<BuildAction>Content</BuildAction>
33+
<BuildAction>None</BuildAction>
3434
</_PackageFiles>
3535
<_PackageFiles Include="$(OutputPath)LuYao.ResourcePacker.dll">
3636
<PackagePath>tasks/$(TargetFramework)</PackagePath>
3737
<Visible>false</Visible>
38-
<BuildAction>Content</BuildAction>
38+
<BuildAction>None</BuildAction>
3939
</_PackageFiles>
4040
<_PackageFiles Include="$(OutputPath)LuYao.ResourcePacker.SourceGenerator.dll">
4141
<PackagePath>analyzers/dotnet/cs</PackagePath>
4242
<Visible>false</Visible>
43-
<BuildAction>Content</BuildAction>
43+
<BuildAction>None</BuildAction>
4444
</_PackageFiles>
4545
</ItemGroup>
4646
</Target>

LuYao.ResourcePacker.MSBuild/build/LuYao.ResourcePacker.MSBuild.targets

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
<Target Name="PackResources" BeforeTargets="AssignTargetPaths" Condition="'$(ResourcePackerEnabled)' == 'true'">
77
<PropertyGroup>
88
<!-- Use MSBuildProjectName if AssemblyName is not set -->
9-
<_AssemblyNameForPacker Condition="'$(AssemblyName)' != ''">$(AssemblyName)</_AssemblyNameForPacker>
10-
<_AssemblyNameForPacker Condition="'$(AssemblyName)' == ''">$(MSBuildProjectName)</_AssemblyNameForPacker>
9+
<_AssemblyNameForPacker>$([MSBuild]::ValueOrDefault('$(AssemblyName)', '$(MSBuildProjectName)'))</_AssemblyNameForPacker>
1110
<ResourcePackerOutputFileName Condition="'$(ResourcePackerOutputFileName)' == ''">$(_AssemblyNameForPacker).dat</ResourcePackerOutputFileName>
1211
</PropertyGroup>
1312
<ResourcePackerTask

test-scenario/LibA/LibA.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</ItemGroup>
1212

1313
<ItemGroup>
14-
<None Include="Resources\**\*.res.*" CopyToOutputDirectory="Never" />
14+
<None Include="Resources\**\*.res.*" />
1515
</ItemGroup>
1616

1717
</Project>

test-scenario/README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Test Scenario: Non-Transitive Dependency
2+
3+
This test scenario demonstrates that the MSBuild and Source Generator components of LuYao.ResourcePacker.MSBuild are NOT transitively referenced.
4+
5+
## Project Structure
6+
7+
```
8+
LibA (references LuYao.ResourcePacker.MSBuild via NuGet)
9+
└── Contains test.res.txt resource file
10+
└── Generates LibA.dat during build
11+
12+
LibB (references LibA)
13+
└── Does NOT get MSBuild/SG functionality
14+
└── Does receive LibA.dat in output
15+
16+
App2 (references LibB)
17+
└── Does NOT get MSBuild/SG functionality
18+
└── Does receive LibA.dat in output
19+
```
20+
21+
## Expected Behavior
22+
23+
1. **LibA**: MSBuild targets execute, generates `LibA.dat`
24+
2. **LibB**: MSBuild targets do NOT execute (no transitive import), but `LibA.dat` is copied to output
25+
3. **App2**: MSBuild targets do NOT execute (no transitive import), but `LibA.dat` is copied to output
26+
27+
## Testing
28+
29+
```bash
30+
# Build the entire chain
31+
cd test-scenario
32+
dotnet build App2/App2.csproj
33+
34+
# Verify LibA has LibA.dat
35+
ls LibA/bin/Debug/net8.0/LibA.dat
36+
37+
# Verify LibB has LibA.dat but NOT LibB.dat
38+
ls LibB/bin/Debug/net8.0/LibA.dat
39+
ls LibB/bin/Debug/net8.0/LibB.dat # Should not exist
40+
41+
# Verify App2 has LibA.dat
42+
ls App2/bin/Debug/net8.0/LibA.dat
43+
```
44+
45+
## Key Points
46+
47+
- The `LuYao.ResourcePacker.MSBuild` package only imports build assets for **direct** references
48+
- The runtime dependency (`LuYao.ResourcePacker`) **IS** transitively passed
49+
- Generated `.dat` files are copied to all consuming projects via the `CopyToOutputDirectory` setting

0 commit comments

Comments
 (0)