mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-22 10:34:30 +08:00
refactor(build): 优化源代码生成器项目配置
- 移除 GeneratePackageOnBuild 和 IsRoslynComponent 配置项 - 统一设置 IncludeBuildOutput 为 false 以避免运行时库输出 - 更新 Microsoft.CodeAnalysis.Analyzers 版本至 4.14.0 - 为所有项目引用添加 PrivateAssets="all" 属性 - 简化打包配置,只将生成器 DLL 打包到 analyzers 目录 - 添加中文注释说明各配置项的作用和用途
This commit is contained in:
parent
eababa471a
commit
fc88d908be
@ -3,42 +3,38 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PackageId>GeWuYou.GFramework.Godot.SourceGenerators</PackageId>
|
<PackageId>GeWuYou.GFramework.Godot.SourceGenerators</PackageId>
|
||||||
<TargetFramework>netstandard2.0</TargetFramework>
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
<IsRoslynAnalyzer>true</IsRoslynAnalyzer>
|
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
|
||||||
<LangVersion>latest</LangVersion>
|
|
||||||
<IsRoslynComponent>true</IsRoslynComponent>
|
|
||||||
|
|
||||||
<!-- 对 generator 项目要启用扩展规则 -->
|
<!-- 这是 Roslyn Analyzer -->
|
||||||
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
|
<IsRoslynAnalyzer>true</IsRoslynAnalyzer>
|
||||||
<!-- 不把输出当作运行时库 -->
|
|
||||||
<IncludeBuildOutput>false</IncludeBuildOutput>
|
<IncludeBuildOutput>false</IncludeBuildOutput>
|
||||||
<!-- 有助于调试生成的代码(可选) -->
|
|
||||||
|
<LangVersion>latest</LangVersion>
|
||||||
|
|
||||||
|
<!-- 可选:调试生成代码 -->
|
||||||
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
|
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
|
||||||
<CompilerGeneratedFilesOutputPath>Generated</CompilerGeneratedFilesOutputPath>
|
<CompilerGeneratedFilesOutputPath>Generated</CompilerGeneratedFilesOutputPath>
|
||||||
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<!-- Roslyn 依赖(仅 Generator 自用) -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.14.0"/>
|
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.14.0" PrivateAssets="all"/>
|
||||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.14.0"/>
|
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="4.14.0" PrivateAssets="all"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<!-- Generator 编译期依赖 -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<!-- Generator 需要引用 Attributes 项目,但不作为运行时依赖 -->
|
|
||||||
<ProjectReference Include="..\GFramework.Godot.SourceGenerators.Attributes\GFramework.Godot.SourceGenerators.Attributes.csproj"
|
<ProjectReference Include="..\GFramework.Godot.SourceGenerators.Attributes\GFramework.Godot.SourceGenerators.Attributes.csproj"
|
||||||
PrivateAssets="all"/>
|
PrivateAssets="all"/>
|
||||||
<ProjectReference Include="..\GFramework.SourceGenerators.Common\GFramework.SourceGenerators.Common.csproj"/>
|
<ProjectReference Include="..\GFramework.SourceGenerators.Common\GFramework.SourceGenerators.Common.csproj"
|
||||||
|
PrivateAssets="all"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<!-- 将 Generator 和 Attributes DLL 打包为 Analyzer -->
|
|
||||||
|
<!-- ★唯一需要打包的东西:Generator DLL -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="$(OutputPath)\$(AssemblyName).dll" Pack="true"
|
<None Include="$(OutputPath)\$(AssemblyName).dll"
|
||||||
PackagePath="analyzers/dotnet/cs" Visible="false"/>
|
Pack="true"
|
||||||
<None Include="$(OutputPath)$(AssemblyName).dll" Pack="true" PackagePath="lib/netstandard2.0"/>
|
PackagePath="analyzers/dotnet/cs"
|
||||||
<None Include="$(OutputPath)\GFramework.Godot.SourceGenerators.Attributes.dll" Pack="true"
|
Visible="false"/>
|
||||||
PackagePath="analyzers/dotnet/cs" Visible="false"/>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<AdditionalFiles Include="AnalyzerReleases.Shipped.md"/>
|
|
||||||
<AdditionalFiles Include="AnalyzerReleases.Unshipped.md"/>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@ -3,41 +3,39 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PackageId>GeWuYou.GFramework.SourceGenerators</PackageId>
|
<PackageId>GeWuYou.GFramework.SourceGenerators</PackageId>
|
||||||
<TargetFramework>netstandard2.0</TargetFramework>
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
<IsRoslynAnalyzer>true</IsRoslynAnalyzer>
|
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
|
||||||
<LangVersion>latest</LangVersion>
|
|
||||||
<IsRoslynComponent>true</IsRoslynComponent>
|
|
||||||
|
|
||||||
<!-- 对 generator 项目要启用扩展规则 -->
|
<!-- 这是 Analyzer,不是运行时库 -->
|
||||||
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
|
<IsRoslynAnalyzer>true</IsRoslynAnalyzer>
|
||||||
<!-- 不把输出当作运行时库 -->
|
|
||||||
<IncludeBuildOutput>false</IncludeBuildOutput>
|
<IncludeBuildOutput>false</IncludeBuildOutput>
|
||||||
<!-- 有助于调试生成的代码(可选) -->
|
|
||||||
|
<LangVersion>latest</LangVersion>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
|
||||||
|
<!-- 可选:调试生成代码 -->
|
||||||
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
|
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
|
||||||
<CompilerGeneratedFilesOutputPath>Generated</CompilerGeneratedFilesOutputPath>
|
<CompilerGeneratedFilesOutputPath>Generated</CompilerGeneratedFilesOutputPath>
|
||||||
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<!-- Roslyn 依赖,只用于 Generator 自身 -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.14.0" PrivateAssets="all"/>
|
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.14.0" PrivateAssets="all"/>
|
||||||
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0" PrivateAssets="all"/>
|
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="4.14.0" PrivateAssets="all"/>
|
||||||
<PackageReference Include="System.Collections.Immutable" Version="9.0.0"/>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<!-- Generator 编译期引用 Attributes / Common,但不打包 -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<!-- Generator 需要引用 Attributes 项目,但不作为运行时依赖 -->
|
|
||||||
<ProjectReference Include="..\GFramework.SourceGenerators.Attributes\GFramework.SourceGenerators.Attributes.csproj"
|
<ProjectReference Include="..\GFramework.SourceGenerators.Attributes\GFramework.SourceGenerators.Attributes.csproj"
|
||||||
PrivateAssets="all"/>
|
PrivateAssets="all"/>
|
||||||
<ProjectReference Include="..\GFramework.SourceGenerators.Common\GFramework.SourceGenerators.Common.csproj"/>
|
<ProjectReference Include="..\GFramework.SourceGenerators.Common\GFramework.SourceGenerators.Common.csproj"
|
||||||
|
PrivateAssets="all"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- 将 Generator 和 Attributes DLL 打包为 Analyzer -->
|
<!-- ★关键:只把 Generator DLL 放进 analyzers -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="$(OutputPath)\$(AssemblyName).dll" Pack="true"
|
<None Include="$(OutputPath)\$(AssemblyName).dll"
|
||||||
PackagePath="analyzers/dotnet/cs" Visible="false"/>
|
Pack="true"
|
||||||
<None Include="$(OutputPath)$(AssemblyName).dll" Pack="true" PackagePath="lib/netstandard2.0"/>
|
PackagePath="analyzers/dotnet/cs"
|
||||||
<None Include="$(OutputPath)\GFramework.SourceGenerators.Attributes.dll" Pack="true"
|
Visible="false"/>
|
||||||
PackagePath="analyzers/dotnet/cs" Visible="false"/>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user