从 ANTLR 生成的文件在发布和调试模式之间 visual studio 发生冲突
generated files from ANTLR conflict in visual studio between release and debug modes
我将 ANTLR4
与 Visual Studio
和 C#
一起使用。在构建过程中,ANTLR4
工具生成 6 个 C#
源文件(即 Parser、Lexer、Visitor、Listener 等),它们对应于 ANTLR
生成的解析器。这些文件在项目的 obj/Debug 目录中生成(假设选择了调试模式)。我将这些文件作为链接添加到解决方案资源管理器中以检查生成的代码。
如果我尝试更改为发布模式 ANTLR4
在项目的 obj/Release 目录中生成相同的文件并且这些文件存在冲突(在相同的命名空间中重复 类)使用 obj/Debug 目录中生成的文件。
问题是:
当我在发布模式下完成上述操作时,是否有任何方法可以从调试模式(在发布模式下)中排除解决方案资源管理器中生成的文件,或者我必须手动排除 obj/Debug解决方案资源管理器中的目录以避免冲突?
提前致谢
我为同样的问题苦苦挣扎。主要问题是,已将文件链接到项目 DEBUG 配置。因此,当您切换到 RELEASE 配置时,链接仍然存在,现在您的项目中有重复的定义。 obj/DEBUG路径中的可见项和obj/RELEASE路径中的不可见项
我不知道有什么方法可以在 VS-GUI 上解决这个问题。但是可以修补 cproj 文件以获得可接受的解决方案:
首先是原文部分:
...
<ItemGroup>
<Compile Include="DataRepository.cs" />
<Compile Include="SpreadsheetErrorListener.cs" />
<Compile Include="SpreadsheetVisitor.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="obj\Debug\SpreadsheetBaseListener.cs" />
<Compile Include="obj\Debug\SpreadsheetBaseVisitor.cs" />
<Compile Include="obj\Debug\SpreadsheetLexer.cs" />
<Compile Include="obj\Debug\SpreadsheetListener.cs" />
<Compile Include="obj\Debug\SpreadsheetParser.cs" />
<Compile Include="obj\Debug\SpreadsheetVisitor.cs" />
</ItemGroup>
...
你的看起来应该很相似。
我将 ItemGroups 拆分为:
...
<ItemGroup>
<Compile Include="DataRepository.cs" />
<Compile Include="SpreadsheetErrorListener.cs" />
<Compile Include="SpreadsheetVisitor.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Compile Include="obj\Release\SpreadsheetBaseListener.cs" />
<Compile Include="obj\Release\SpreadsheetBaseVisitor.cs" />
<Compile Include="obj\Release\SpreadsheetLexer.cs" />
<Compile Include="obj\Release\SpreadsheetListener.cs" />
<Compile Include="obj\Release\SpreadsheetParser.cs" />
<Compile Include="obj\Release\SpreadsheetVisitor.cs" />
</ItemGroup>
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<Compile Include="obj\Debug\SpreadsheetBaseListener.cs" />
<Compile Include="obj\Debug\SpreadsheetBaseVisitor.cs" />
<Compile Include="obj\Debug\SpreadsheetLexer.cs" />
<Compile Include="obj\Debug\SpreadsheetListener.cs" />
<Compile Include="obj\Debug\SpreadsheetParser.cs" />
<Compile Include="obj\Debug\SpreadsheetVisitor.cs" />
</ItemGroup>
...
在 VS 中,两个目录都是可见的,但只有一个用于 Intellisense 和编译期间。
当前选择的文件显示为"openers"(抱歉不知道正确的名称)
DEBUG configuration
RELEASE configuration
看起来不太好,但解决了问题。
缺点:
每次添加新配置时都必须再次修补 cproj 文件。但这样做是值得的,因为 Intellisense、Resharper 和所有其他不错的小帮手都可以工作。
我将 ANTLR4
与 Visual Studio
和 C#
一起使用。在构建过程中,ANTLR4
工具生成 6 个 C#
源文件(即 Parser、Lexer、Visitor、Listener 等),它们对应于 ANTLR
生成的解析器。这些文件在项目的 obj/Debug 目录中生成(假设选择了调试模式)。我将这些文件作为链接添加到解决方案资源管理器中以检查生成的代码。
如果我尝试更改为发布模式 ANTLR4
在项目的 obj/Release 目录中生成相同的文件并且这些文件存在冲突(在相同的命名空间中重复 类)使用 obj/Debug 目录中生成的文件。
问题是:
当我在发布模式下完成上述操作时,是否有任何方法可以从调试模式(在发布模式下)中排除解决方案资源管理器中生成的文件,或者我必须手动排除 obj/Debug解决方案资源管理器中的目录以避免冲突?
提前致谢
我为同样的问题苦苦挣扎。主要问题是,已将文件链接到项目 DEBUG 配置。因此,当您切换到 RELEASE 配置时,链接仍然存在,现在您的项目中有重复的定义。 obj/DEBUG路径中的可见项和obj/RELEASE路径中的不可见项
我不知道有什么方法可以在 VS-GUI 上解决这个问题。但是可以修补 cproj 文件以获得可接受的解决方案:
首先是原文部分:
...
<ItemGroup>
<Compile Include="DataRepository.cs" />
<Compile Include="SpreadsheetErrorListener.cs" />
<Compile Include="SpreadsheetVisitor.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="obj\Debug\SpreadsheetBaseListener.cs" />
<Compile Include="obj\Debug\SpreadsheetBaseVisitor.cs" />
<Compile Include="obj\Debug\SpreadsheetLexer.cs" />
<Compile Include="obj\Debug\SpreadsheetListener.cs" />
<Compile Include="obj\Debug\SpreadsheetParser.cs" />
<Compile Include="obj\Debug\SpreadsheetVisitor.cs" />
</ItemGroup>
...
你的看起来应该很相似。
我将 ItemGroups 拆分为:
...
<ItemGroup>
<Compile Include="DataRepository.cs" />
<Compile Include="SpreadsheetErrorListener.cs" />
<Compile Include="SpreadsheetVisitor.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Compile Include="obj\Release\SpreadsheetBaseListener.cs" />
<Compile Include="obj\Release\SpreadsheetBaseVisitor.cs" />
<Compile Include="obj\Release\SpreadsheetLexer.cs" />
<Compile Include="obj\Release\SpreadsheetListener.cs" />
<Compile Include="obj\Release\SpreadsheetParser.cs" />
<Compile Include="obj\Release\SpreadsheetVisitor.cs" />
</ItemGroup>
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<Compile Include="obj\Debug\SpreadsheetBaseListener.cs" />
<Compile Include="obj\Debug\SpreadsheetBaseVisitor.cs" />
<Compile Include="obj\Debug\SpreadsheetLexer.cs" />
<Compile Include="obj\Debug\SpreadsheetListener.cs" />
<Compile Include="obj\Debug\SpreadsheetParser.cs" />
<Compile Include="obj\Debug\SpreadsheetVisitor.cs" />
</ItemGroup>
...
在 VS 中,两个目录都是可见的,但只有一个用于 Intellisense 和编译期间。
当前选择的文件显示为"openers"(抱歉不知道正确的名称)
DEBUG configuration
RELEASE configuration
看起来不太好,但解决了问题。
缺点:
每次添加新配置时都必须再次修补 cproj 文件。但这样做是值得的,因为 Intellisense、Resharper 和所有其他不错的小帮手都可以工作。