git 如何修复损坏的 csproj 文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30414898/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I fix a Corrupted csproj file?
提问by Chrisaboo
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 使用来自 master-branch 的新更新来重新设置我的分支。当 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>
回答by nagaraj mbhat
Just delete below type of text's in csproj file
只需在 csproj 文件中删除以下类型的文本
***<<<<<<<<<<<<<<<
***<<<<<<<<<<<<<<<<
---------Mine
- - - - -矿
'>>>>>>>>>>>>>>>>>>>***
'>>>>>>>>>>>>>>>>>>>***
And reload project again it will work.
并再次重新加载项目它将起作用。
回答by shreyamsh
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 中的文件夹级别而不是解决方案级别更新项目。
回答by LancelotHolmes
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 stylesheet,然后我修复了csproject文件中的合并冲突并打开项目,最后解决了项目中的其他冲突。