diff --git a/LuYao.ResourcePacker.MSBuild/LuYao.ResourcePacker.MSBuild.csproj b/LuYao.ResourcePacker.MSBuild/LuYao.ResourcePacker.MSBuild.csproj index 0f6e40f..a533bd3 100644 --- a/LuYao.ResourcePacker.MSBuild/LuYao.ResourcePacker.MSBuild.csproj +++ b/LuYao.ResourcePacker.MSBuild/LuYao.ResourcePacker.MSBuild.csproj @@ -5,6 +5,7 @@ true MSBuild tasks for LuYao.ResourcePacker - enables automatic resource file packaging during build tasks + false @@ -13,7 +14,9 @@ - + + + @@ -23,15 +26,21 @@ + + <_PackageFiles Include="$(OutputPath)LuYao.ResourcePacker.MSBuild.dll"> + tasks/$(TargetFramework) + false + None + <_PackageFiles Include="$(OutputPath)LuYao.ResourcePacker.dll"> tasks/$(TargetFramework) false - Content + None <_PackageFiles Include="$(OutputPath)LuYao.ResourcePacker.SourceGenerator.dll"> analyzers/dotnet/cs false - Content + None diff --git a/LuYao.ResourcePacker.MSBuild/build/LuYao.ResourcePacker.MSBuild.props b/LuYao.ResourcePacker.MSBuild/build/LuYao.ResourcePacker.MSBuild.props index ddeb67f..8410253 100644 --- a/LuYao.ResourcePacker.MSBuild/build/LuYao.ResourcePacker.MSBuild.props +++ b/LuYao.ResourcePacker.MSBuild/build/LuYao.ResourcePacker.MSBuild.props @@ -4,7 +4,6 @@ true *.res.* internal - $(AssemblyName).dat diff --git a/LuYao.ResourcePacker.MSBuild/build/LuYao.ResourcePacker.MSBuild.targets b/LuYao.ResourcePacker.MSBuild/build/LuYao.ResourcePacker.MSBuild.targets index 1c16a6a..b34d26e 100644 --- a/LuYao.ResourcePacker.MSBuild/build/LuYao.ResourcePacker.MSBuild.targets +++ b/LuYao.ResourcePacker.MSBuild/build/LuYao.ResourcePacker.MSBuild.targets @@ -5,12 +5,14 @@ - $(AssemblyName).dat + + <_AssemblyNameForPacker>$([MSBuild]::ValueOrDefault('$(AssemblyName)', '$(MSBuildProjectName)')) + $(_AssemblyNameForPacker).dat diff --git a/test-scenario/App2/App2.csproj b/test-scenario/App2/App2.csproj new file mode 100644 index 0000000..affa2f9 --- /dev/null +++ b/test-scenario/App2/App2.csproj @@ -0,0 +1,14 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + diff --git a/test-scenario/App2/Program.cs b/test-scenario/App2/Program.cs new file mode 100644 index 0000000..2a8c750 --- /dev/null +++ b/test-scenario/App2/Program.cs @@ -0,0 +1,4 @@ +using LibB; + +Console.WriteLine(new LibBClass().GetMessage()); +Console.WriteLine("App2 is running"); diff --git a/test-scenario/LibA/LibA.csproj b/test-scenario/LibA/LibA.csproj new file mode 100644 index 0000000..db86f40 --- /dev/null +++ b/test-scenario/LibA/LibA.csproj @@ -0,0 +1,17 @@ + + + + net8.0 + enable + enable + + + + + + + + + + + diff --git a/test-scenario/LibA/LibAClass.cs b/test-scenario/LibA/LibAClass.cs new file mode 100644 index 0000000..7e965ab --- /dev/null +++ b/test-scenario/LibA/LibAClass.cs @@ -0,0 +1,6 @@ +namespace LibA; + +public class LibAClass +{ + public string GetMessage() => "Hello from LibA"; +} diff --git a/test-scenario/LibA/Resources/test.res.txt b/test-scenario/LibA/Resources/test.res.txt new file mode 100644 index 0000000..5143624 --- /dev/null +++ b/test-scenario/LibA/Resources/test.res.txt @@ -0,0 +1 @@ +This is a test resource from LibA diff --git a/test-scenario/LibB/LibB.csproj b/test-scenario/LibB/LibB.csproj new file mode 100644 index 0000000..9476e5f --- /dev/null +++ b/test-scenario/LibB/LibB.csproj @@ -0,0 +1,13 @@ + + + + net8.0 + enable + enable + + + + + + + diff --git a/test-scenario/LibB/LibBClass.cs b/test-scenario/LibB/LibBClass.cs new file mode 100644 index 0000000..93b95ef --- /dev/null +++ b/test-scenario/LibB/LibBClass.cs @@ -0,0 +1,6 @@ +namespace LibB; + +public class LibBClass +{ + public string GetMessage() => "Hello from LibB"; +} diff --git a/test-scenario/NuGet.config b/test-scenario/NuGet.config new file mode 100644 index 0000000..17c5948 --- /dev/null +++ b/test-scenario/NuGet.config @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/test-scenario/README.md b/test-scenario/README.md new file mode 100644 index 0000000..d4a97c2 --- /dev/null +++ b/test-scenario/README.md @@ -0,0 +1,49 @@ +# Test Scenario: Non-Transitive Dependency + +This test scenario demonstrates that the MSBuild and Source Generator components of LuYao.ResourcePacker.MSBuild are NOT transitively referenced. + +## Project Structure + +``` +LibA (references LuYao.ResourcePacker.MSBuild via NuGet) + └── Contains test.res.txt resource file + └── Generates LibA.dat during build + +LibB (references LibA) + └── Does NOT get MSBuild/SG functionality + └── Does receive LibA.dat in output + +App2 (references LibB) + └── Does NOT get MSBuild/SG functionality + └── Does receive LibA.dat in output +``` + +## Expected Behavior + +1. **LibA**: MSBuild targets execute, generates `LibA.dat` +2. **LibB**: MSBuild targets do NOT execute (no transitive import), but `LibA.dat` is copied to output +3. **App2**: MSBuild targets do NOT execute (no transitive import), but `LibA.dat` is copied to output + +## Testing + +```bash +# Build the entire chain +cd test-scenario +dotnet build App2/App2.csproj + +# Verify LibA has LibA.dat +ls LibA/bin/Debug/net8.0/LibA.dat + +# Verify LibB has LibA.dat but NOT LibB.dat +ls LibB/bin/Debug/net8.0/LibA.dat +ls LibB/bin/Debug/net8.0/LibB.dat # Should not exist + +# Verify App2 has LibA.dat +ls App2/bin/Debug/net8.0/LibA.dat +``` + +## Key Points + +- The `LuYao.ResourcePacker.MSBuild` package only imports build assets for **direct** references +- The runtime dependency (`LuYao.ResourcePacker`) **IS** transitively passed +- Generated `.dat` files are copied to all consuming projects via the `CopyToOutputDirectory` setting