每當我試圖編譯在VS2012任何WPF項目我有以下的編譯錯誤:錯誤讀取資源文件的任何WPF項目在VS2012
Error reading resource file 'c:\Users\mysuerID\Documents\Visual Studio 2012\Projects\MyAppNAme\MyAppNAme\obj\Debug\' -- 'The system cannot find the path specified. ' C:\Users\mysuerID\Documents\Visual Studio 2012\Projects\MyAppNAme\MyAppNAme\CSC MyAppNAme
問題是,當VS產生CSC的命令,它包含一個額外的部分複製/資源參數是這樣的:
/resource:obj\Debug\ /resource:obj\Debug\MyAppName.Properties.Resources.resources
CSC看起來只在第一個參數,因爲沒有文件名指定它拋出的錯誤。我進入了命令行模式,並在沒有額外參數的情況下進行測試,並驗證它是問題所在。我不想手動編譯我的項目!
任何人都知道VS如何提出這些參數,以及如何擺脫這個額外的無效參數?
生成輸出看起來像這樣(框架4.5)
1>Target "MainResourcesGeneration" in file "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.WinFX.targets" from project "C:\Users\jws15592\Documents\Visual Studio 2012\Projects\MyAppName\MyAppName\MyAppName.csproj" (target "PrepareResources" depends on it):
1>Building target "MainResourcesGeneration" completely.
1>Input file "C:\Users\jws15592\Documents\Visual Studio 2012\Projects\MyAppName\MyAppName\obj\Debug\MainWindow.baml" is newer than output file "obj\Debug\".
1>Task "Message" skipped, due to false condition; ('$(MSBuildTargetsVerbose)'=='true') was evaluated as (''=='true').
1>Using "ResourcesGenerator" task from assembly "PresentationBuildTasks, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35".
1>Task "ResourcesGenerator"
1>
1>
1> Microsoft (R) Build Task 'ResourcesGenerator' Version '4.0.30319.17929 built by: FX45RTMREL'.
1> Copyright (C) Microsoft Corporation 2005. All rights reserved.
1>
1>
1> Generating .resources file: 'obj\Debug\'...
1>C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.WinFX.targets(709,5): error RG1000: Unknown build error, 'Could not find a part of the path 'C:\Users\jws15592\Documents\Visual Studio 2012\Projects\MyAppName\MyAppName\obj\Debug\'.'
1>Done executing task "ResourcesGenerator" -- FAILED.
1>Done building target "MainResourcesGeneration" in project "MyAppName.csproj" -- FAILED.
中的ItemGroup在項目文件:
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="app.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<AppDesigner Include="Properties\" />
</ItemGroup>
順便說一句,我試着卸載Visual Studio並重新安裝。根本沒有效果。 – Jeff