I am trying to reference DotLiquid in an incremental source generator. I have no compilation errors. However, in runtime I get "Could not load file or assembly 'DotLiquid, Version=2.2.692.0, Culture=neutral, PublicKeyToken=82e46016ecf9f07c'. The system cannot find the file specified." How I can fix it ?
I've tried to use approach from Source Generators Cookbook
My generator's csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<IsPackable>false</IsPackable>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
<IsRoslynComponent>true</IsRoslynComponent>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<IncludeBuildOutput>false</IncludeBuildOutput>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DotLiquid" Version="2.2.692" PrivateAssets="all" GeneratePathProperty="true" />
<None Include="$(OutputPath)\$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
<None Include="$(PkgDotLiquid)\lib\netstandard2.0\*.dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers"
Version="3.3.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.6.0"/>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces"
Version="4.6.0"/>
</ItemGroup>
</Project>
My incremental source generator:
using DotLiquid;
using Microsoft.CodeAnalysis;
namespace SourceGenerators1;
[Generator]
public class TestGenerator : IIncrementalGenerator
{
public void Initialize(IncrementalGeneratorInitializationContext context)
{
var template = Template.Parse("");
}
}