Loading

Source Generator 设置

netstandard2.0

引入

    <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.11.0" PrivateAssets="all" />
    <PackageReference Include="Scripty.MsBuild" Version="0.7.4">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
<PropertyGroup>	<CompilerGeneratedFilesOutputPath>$(MSBuildProjectDirectory)\GeneratedFiles</CompilerGeneratedFilesOutputPath>
		<GenerateDocumentationFile>True</GenerateDocumentationFile>
	</PropertyGroup>


	<ItemGroup> 
	  <ProjectReference Include="..\SourceGenerate\SourceGenerate.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
		<EmbeddedResource Remove="GeneratedFiles\**" />
		<Compile Remove="GeneratedFiles\**" />
		<None Remove="GeneratedFiles\**" />
	</ItemGroup>

未整理

	<PropertyGroup>
		<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
		<CompilerGeneratedFilesOutputPath>$(MSBuildProjectDirectory)</CompilerGeneratedFilesOutputPath>
		<GenerateDocumentationFile>true</GenerateDocumentationFile>
	</PropertyGroup>
	<PropertyGroup>
		<IsRemoveCompilerFiles>true</IsRemoveCompilerFiles>
	</PropertyGroup>
	<ItemGroup Condition="false">
		<Compile Remove="CodeAutoGenerate.Contracts\**" />
		<EmbeddedResource Remove="CodeAutoGenerate.Contracts\**" />
		<None Remove="CodeAutoGenerate.Contracts\**" />
	</ItemGroup>
	<ItemGroup>
		<ProjectReference Include="..\CodeAutoGenerate.Contracts\CodeAutoGenerate.Contracts.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
	</ItemGroup>

	<Target Name="BeforeBuild">
		<RemoveDir Directories="$(MSBuildProjectDirectory)" />
	</Target>

	<ItemGroup>
		<Compile Remove="CodeAutoGenerate.Contracts\**" />
	</ItemGroup>
	<Target Name="AfterAnalyzer" BeforeTargets="CoreCompile">
	</Target>
posted @ 2025-03-12 22:37  一起滚月球  阅读(10)  评论(0)    收藏  举报