如何修复损坏的csproj文件?

时间:2023-01-13 21:47:18

I'm in a group working on a project, and was about to Rebase my branch with the new updates from master-branch using git. When rebase started, it suddenly breaks down and gives me this error message:

我是一个正在研究项目的小组,并且正准备使用git从主分支重新启动我的分支。当rebase启动时,它突然崩溃并给我这个错误消息:

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

The "csproj" file seems to be corrupted. How can i fix this? The problem looks like this:

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

2 个解决方案

#1


0  

I also encountered such a problem when I want to merge with my friend on a ASP.NET MVC project, and the problem is that when I use git to merge our project, there are several differences in the file of .csproject so that I cannot open the project;

当我想在ASP.NET MVC项目上与我的朋友合并时,我也遇到了这样的问题,问题是当我使用git合并我们的项目时,.csproject的文件有几个不同,所以我不能打开项目;

Finally I open the file by using sublime and find that the problem is that I have added sevaral css stylesheet to the project, then I repair the merge conflict in the csproject file and open the project and finally solve other conflicts in the project.

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

#2


-1  

I agree Chrisaboo. The problem is in the project file. Whenever you update your solution in Visual Studio, there is a possibility of a merge conflict. You can resolve this by comparing your project file with the previous version and eliminating the differences in a text editor or the version control tool. This resolved the issue for me.

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

It is recommended to update the project on a folder level in Visual Studio rather than the solution level.

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

#1


0  

I also encountered such a problem when I want to merge with my friend on a ASP.NET MVC project, and the problem is that when I use git to merge our project, there are several differences in the file of .csproject so that I cannot open the project;

当我想在ASP.NET MVC项目上与我的朋友合并时,我也遇到了这样的问题,问题是当我使用git合并我们的项目时,.csproject的文件有几个不同,所以我不能打开项目;

Finally I open the file by using sublime and find that the problem is that I have added sevaral css stylesheet to the project, then I repair the merge conflict in the csproject file and open the project and finally solve other conflicts in the project.

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

#2


-1  

I agree Chrisaboo. The problem is in the project file. Whenever you update your solution in Visual Studio, there is a possibility of a merge conflict. You can resolve this by comparing your project file with the previous version and eliminating the differences in a text editor or the version control tool. This resolved the issue for me.

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

It is recommended to update the project on a folder level in Visual Studio rather than the solution level.

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