无法访问包含的文件sourcegenerator
我将此项目组添加到sourcegenerator.csproj文件
<ItemGroup>
<Content Include="defs\*\*.json" CopyToOutputDirectory="PreserveNewest" />
<Content Include="Templates\*.template" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
obs:如果我构建sourcegenerator项目,则将文件复制到输出。
我会得到这样的模板文件的路径:
var path = Path.Combine(AppContext.BaseDirectory, "Templates", _fileName);
但是,在试图编译引用此Sourcecode生成器的项目时,我会收到警告:
Generator 'SourceGenerator' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type 'DirectoryNotFoundException' with message 'Could not find a part of the path 'C:\Program Files\dotnet\sdk\6.0.300-preview.22204.3\Roslyn\bincore\Templates\Struct.template'.'
I added this ItemGroup to the SourceGenerator.csproj file
<ItemGroup>
<Content Include="defs\*\*.json" CopyToOutputDirectory="PreserveNewest" />
<Content Include="Templates\*.template" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
OBS: The files get copied to the output if i build the SourceGenerator project.
I get the path of the template file like this:
var path = Path.Combine(AppContext.BaseDirectory, "Templates", _fileName);
But, while trying to compile the Project that references this SourceCode generator i get an warning:
Generator 'SourceGenerator' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type 'DirectoryNotFoundException' with message 'Could not find a part of the path 'C:\Program Files\dotnet\sdk\6.0.300-preview.22204.3\Roslyn\bincore\Templates\Struct.template'.'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论