如何修复损坏的csproj文件?

时间:2015-05-23 16:15:49

标签: xml git visual-studio rebase csproj

我正在一个项目小组工作,并且正准备使用git从master-branch重新启动我的分支。当rebase开始时,它突然崩溃并给我这个错误信息:

The project file could not be loaded. Name cannot 
begin with the '<' character, hexadecimal value 0x3C.
Line 173, position 2.

&#34; csproj&#34;文件似乎已损坏。我怎样才能解决这个问题?问题看起来像这样:

  <ItemGroup>
    <Compile Include="App_Start\BundleConfig.cs" />
    <Compile Include="App_Start\FilterConfig.cs" />
    <Compile Include="App_Start\IdentityConfig.cs" />
    <Compile Include="App_Start\RouteConfig.cs" />
    <Compile Include="App_Start\Startup.Auth.cs" />
    <Compile Include="App_Start\WebApiConfig.cs" />
    <Compile Include="Controllers\AccountController.cs" />
    <Compile Include="Controllers\CategoryController.cs" />
<<<<<<< HEAD
    <Compile Include="Controllers\GalleryController.cs" />
=======
    <Compile Include="Controllers\CheckoutController.cs" />
>>>>>>> Checkout Works. something wrong with Authorization. No need be logged
    <Compile Include="Controllers\HomeController.cs" />
    <Compile Include="Controllers\ManageController.cs" />
    <Compile Include="Controllers\PhotoController.cs" />
    <Compile Include="Controllers\ShoppingCartController.cs" />
    <Compile Include="Controllers\StoreController.cs" />
    <Compile Include="Controllers\StoreManagerController.cs" />
    <Compile Include="Global.asax.cs">
      <DependentUpon>Global.asax</DependentUpon>
    </Compile>

3 个答案:

答案 0 :(得分:3)

只需在csproj文件中删除以下文本类型

*** <<<<<<<<<<<<<<<< / p>

---------我的

'>>>>>>>>>>>>>>>>>>>>> ***

然后重新加载项目即可。

答案 1 :(得分:0)

当我想在ASP.NET MVC项目上与我的朋友合并时,我也遇到了这样的问题,问题是当我使用git合并我们的项目时,.csproject文件中存在一些差异所以我无法打开项目;

最后我使用sublime打开文件,发现问题是我已经将sevaral css样式表添加到项目中,然后我修复了csproject文件中的合并冲突并打开项目并最终解决了项目中的其他冲突

答案 2 :(得分:0)

我同意Chrisaboo。问题出在项目文件中。每当您在Visual Studio中更新解决方案时,都可能发生合并冲突。您可以通过将项目文件与先前版本进行比较并消除文本编辑器或版本控制工具中的差异来解决此问题。 这解决了我的问题。

建议在Visual Studio而不是解决方案级别更新文件夹级别的项目。