2016-02-05 44 views
1

我使用ANTLR4Visual StudioC#。在構建過程中,ANTLR4工具會生成對應於生成的解析器的6 C#源文件(即Parser,Lexer,Visitor,Listener等)。該文件在項目的obj/Debug目錄中生成(假定選擇了調試模式)。我將這些文件作爲解決方案資源管理器中的鏈接添加以檢查生成的代碼。在發佈和調試模式之間從visual studio中的ANTLR衝突生成的文件

如果我嘗試更改爲發佈模式ANTLR4在項目的obj/Release目錄中生成相同的文件,並且這些文件與obj/Debug目錄中生成的文件發生衝突(同一命名空間中的dublicate類)。

的問題是:

當我在已經完成上述動作釋放模式,有沒有辦法從調試模式排除在解決方案資源管理器中生成的文件(而在釋放模式),或者我有手動排除解決方案資源管理器中的obj/Debug目錄以避免衝突?

在此先感謝

回答

1

我在同一個問題上掙扎。主要問題,已將文件鏈接到項目DEBUG配置。所以當您切換到RELEASE配置時,鏈接仍然存在,現在您的項目中有重複的定義。 obj/DEBUG路徑中的visible和obj/RELEASE路徑中的invisibles我不知道在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兩個目錄是可見的,但只有一個是用於智能感知和編譯過程。

當前所選的文件與「歎爲觀止」(抱歉不知道正確的名稱)

DEBUG configuration

RELEASE configuration

顯示不看不錯,但解決問題。

缺點:

每次添加新的配置,就必須重新修補cproj文件。但這樣做是值得的,因爲Intellisense,Resharper和所有其他漂亮的小幫手都可以工作。

相關問題