我將我的 VB 專案轉換為一個 SDK 風格的專案,一切都很順利,直到我更新了我的My Project\Resources.resx檔案,發現設計器檔案不會更新。為了使設計器檔案隨著對 resx 檔案的更改進行更新,我需要進行哪些更改?
uj5u.com熱心網友回復:
我在此處與 Microsoft 提出的問題中的代碼片段部分組合了此問題的答案:https ://developercommunity.visualstudio.com/t/vs-should-not-bloat-sdk-project-files-with-resx-de /574773
部分來自檢查具有嵌入式資源的非 SDK VB 專案的內容。
添加到專案檔案的以下片段將指示 Visual Studio 自動更新 Resources.resx 的設計器檔案:
<ItemGroup>
<Compile Update="My Project\Resources.Designer.vb">
<AutoGen>true</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="My Project\Resources.resx">
<Generator>VbMyResourcesResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.vb</LastGenOutput>
<CustomToolNamespace>My.Resources</CustomToolNamespace>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
我最初寫了一個更通用的塊(基于鏈接中的材料):
<Compile Update="**\*. Designer.vb">
<DependentUpon>$([System.String]::Copy('%(FileName)'). Replace('. Designer', '.resx'))</DependentUpon>
<LastGenOutput>$([System.String]::Copy('%(FileName)')). Designer.vb</LastGenOutput>
(每個替換上面的等效行)
但我發現 Visual Studio 將特定資源檔案的塊寫入專案檔案(正如鏈接所抱怨的那樣),因此只為特定的 resx/designer 對放置塊似乎更經濟,特別是如果只有一個。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/449365.html
標籤:VB.net
上一篇:面板可見性asp.net
