Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 27, 2025

Issue requests making LuYao.ResourcePacker.MSBuild behave as a development-only NuGet package (like Roslyn analyzers) where it doesn't transitively propagate to downstream projects.

Changes

LuYao.ResourcePacker.MSBuild.csproj

  • Set <DevelopmentDependency>true</DevelopmentDependency> to mark package as build-time tool
  • Changed LuYao.ResourcePacker project reference to PrivateAssets="all" to prevent transitive inclusion

README.md

  • Updated installation instructions to show both packages required

Documentation (Chinese, as requested in issue)

  • PACKAGE_REFERENCE_EXPLANATION.md - Attribute semantics and consequences
  • VERIFICATION_NOTES.md - Package structure verification and migration guide
  • SOLUTION_SUMMARY.md - Technical implementation details
  • FINAL_VERIFICATION.md - Verification checklist
  • LOCAL_NUGET_TEST_RESULTS.md - Comprehensive local NuGet source testing results

Effect

When users install via dotnet add package LuYao.ResourcePacker.MSBuild, NuGet now auto-generates:

<PackageReference Include="LuYao.ResourcePacker.MSBuild" Version="x.x.x">
    <PrivateAssets>all</PrivateAssets>
    <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>

Users must separately install LuYao.ResourcePacker for runtime API access.

Local NuGet Testing

Verified behavior using local NuGet source with comprehensive testing:

  • dotnet add package automatically adds PrivateAssets and IncludeAssets attributes
  • ✅ MSBuild task executes and creates .dat files correctly
  • ✅ Runtime API reads packaged resources successfully
  • ✅ No transitive dependency pollution (tested LibraryProject → ConsumerProject scenario)
  • ✅ Each project must explicitly reference the MSBuild package

See LOCAL_NUGET_TEST_RESULTS.md for detailed test scenarios and results.

Breaking Change

Existing users must add explicit reference to LuYao.ResourcePacker when upgrading. Recommend major version bump.

Original prompt

This section details on the original issue you should resolve

<issue_title>更改 LuYao.ResourcePacker.MSBuild 的默认引用代码</issue_title>
<issue_description>目前,通过 NuGet 引用时,生成的引用代码是这样的:

<PackageReference Include="LuYao.ResourcePacker.MSBuild" Version="0.1.4"/>

但是,客户希望改成下面的样子。

		<PackageReference Include="LuYao.ResourcePacker.MSBuild" Version="0.1.4" OutputItemType="Analyzer" ReferenceOutputAssembly="false">
			<PrivateAssets>all</PrivateAssets>
			<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
		</PackageReference>

经过我的测试,改完之后,需要单独再引用一次 LuYao.ResourcePacker 包,否则会编译失败。我觉得这个可以接受。
同时,对 LuYao.ResourcePacker.MSBuild 的依赖也不会继续传递了,我认为是件好事。

我的需求是:

  1. 请解释一下修改后的代码做了什么事情,会产生什么后果。
  2. 想办法让 NuGet 引用时,默认生成修改后的引用代码。</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 4 commits October 27, 2025 01:42
Co-authored-by: Soar360 <15421284+Soar360@users.noreply.github.com>
…version placeholders

Co-authored-by: Soar360 <15421284+Soar360@users.noreply.github.com>
Co-authored-by: Soar360 <15421284+Soar360@users.noreply.github.com>
Co-authored-by: Soar360 <15421284+Soar360@users.noreply.github.com>
Copilot AI changed the title [WIP] Update default reference code for LuYao.ResourcePacker.MSBuild Configure LuYao.ResourcePacker.MSBuild as development dependency Oct 27, 2025
Copilot AI requested a review from Soar360 October 27, 2025 01:49
Copilot finished work on behalf of Soar360 October 27, 2025 01:49
@Soar360
Copy link
Contributor

Soar360 commented Oct 27, 2025

@copilot 通过构建本地 NuGet 源的方式,测试项目行为是否符合预期。

Co-authored-by: Soar360 <15421284+Soar360@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Oct 27, 2025

@copilot 通过构建本地 NuGet 源的方式,测试项目行为是否符合预期。

已完成本地 NuGet 源测试。测试结果见提交 ff71b29

测试验证了以下场景:

  1. dotnet add package LuYao.ResourcePacker.MSBuild 自动添加 PrivateAssets="all"IncludeAssets 属性
  2. ✅ MSBuild 任务正常执行,生成 .dat 文件
  3. ✅ 运行时 API 正确读取打包的资源
  4. ✅ 依赖不传递:LibraryProject → ConsumerProject 的引用中,ConsumerProject 没有获得 MSBuild 包

详细测试结果见 LOCAL_NUGET_TEST_RESULTS.md 文档。

Copilot finished work on behalf of Soar360 October 27, 2025 01:58
@Soar360 Soar360 marked this pull request as ready for review October 27, 2025 01:58
@Soar360 Soar360 merged commit 0526eb4 into main Oct 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

更改 LuYao.ResourcePacker.MSBuild 的默认引用代码

2 participants