【问题标题】:How do I fix a Corrupted csproj file?如何修复损坏的 csproj 文件?
【发布时间】:2015-05-23 16:15:48
【问题描述】:

我在一个项目组中工作,并且正准备使用 git 使用来自 master-branch 的新更新来重新定位我的分支。当 rebase 开始时,它突然崩溃并给我这个错误消息:

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

“csproj”文件似乎已损坏。我怎样才能解决这个问题?问题如下:

  <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>

【问题讨论】:

  • 是交互式变基吗?是否可以删除所有与项目相关的文件并重新导入项目? (尝试备份)
  • 顺便说一句,csproj 和其他 IDE 相关的文件通常不受版本控制。它们应该被添加到 .gitignore
  • @NickVolynkin 嗨。尝试重新导入项目。没有运气。仍然收到错误消息,并且卡在“rebase 1/2”上。您是说 csproj 不应该在主文件中吗?我应该删除它吗?
  • 过了一会儿,我找到了解决方案。事实证明它非常简单。如果您有同样的问题,请查看此:github.com/articles/resolving-a-merge-conflict
  • @NickVolynkin csproj 文件绝对是源代码控制的候选者。

标签: xml git visual-studio rebase csproj


【解决方案1】:

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

***

---------我的

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

然后重新加载项目它会工作。

【讨论】:

    【解决方案2】:

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

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

    【讨论】:

    • 它合并冲突问题,删除 >>>>>> Checkout Works 后工作正常。授权有问题。无需登录
    【解决方案3】:

    我想和朋友在一个ASP.NET MVC项目上合并的时候也遇到过这样的问题,问题是我用git合并我们的项目时,.csproject的文件有几个不同所以我无法打开项目;

    最后我用sublime打开文件,发现问题是我在项目中添加了几个css样式表,然后我修复csproject文件中的合并冲突并打开项目,最后解决了项目中的其他冲突.

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-02-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-27
      • 1970-01-01
      相关资源
      最近更新 更多