查找并删除 csproj 文件中的重复条目 [英] Find and remove duplicate entries in csproj file

查看:30
本文介绍了查找并删除 csproj 文件中的重复条目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们最近合并了两个代码分支,结果在 .csproj 文件中的几个文件中出现了重复的条目.这似乎发生在所有需要将复制到输出目录"更改为复制"的文件中,这些文件总是在进行更改并与其他分支合并后发生.

We recently merged two branches of code and ended up with duplicate entries for several of the files in the .csproj file. This seemed to happen to all the files which needed the Copy to Output Directory to be changed to Copy always after that change was made and merged with the other branch.

我想知道如果这样留下来是否会导致任何意外问题以及我应该怎么做来解决它.它有很多文件,所以我不想手动检查每个文件.它也不是所有文件,但它是大量文件.我该怎么办?

I was wondering if this is going to cause any unexpected problems if it is left like this and what I should do to fix it. It's a lot of files so I don't want to go through and do it for each file manually. It is also not all of the files, but it is a significant number of files. What should I do?

推荐答案

我最终做的是从项目中删除所有受影响的文件,刷新解决方案资源管理器并显示所有文件,包括不再在项目中的文件,然后将文件重新包含到项目中.

What I ended up doing was to remove all the files from the project that were affected, refreshed the solution explorer and showed all files including ones no longer in the project, and then re-included the files to the project.

我第一次尝试时没有刷新解决方案资源管理器,它也没有改变任何东西,但是在将所有文件从项目中删除后刷新并切换显示/隐藏几次后,包括它们回来只添加了一个引用它们一次而不是我看到的两次.

The first time I tried I didn't refresh the solution explorer and it didn't change anything, but after refreshing and toggling show/hide all files a few times after removing them from the project, including them back only added a reference to them once instead of the twice that I was seeing.

真正使这快速的是我可以通过使用 shift-click 和 ctrl-click 来选择我想要处理的所有文件,然后右键单击以对它们作为一个组执行任何操作,例如从项目中排除,包括在项目中,或更改复制到输出目录设置.

What really made this quick was that I could select all the files I wanted to work with by using shift-click and ctrl-click and then right clicking to perform whatever action on them as a group, such as excluding from the project, including in the project, or changing the copy to output directory setting.

这篇关于查找并删除 csproj 文件中的重复条目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆