TFS/Visual Studio:CS0101:名称空间已经包含className的定义 [英] TFS / Visual Studio : CS0101: The namespace already contains a definition for className

查看:498
本文介绍了TFS/Visual Studio:CS0101:名称空间已经包含className的定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Visual Studio 2019签入时遇到问题.回购在TFS中.我有两个视图模型文件夹,一个用于后端安全站点,一个用于公共前端站点.每个文件夹中都有60多个视图模型,这使解决方案资源管理器的导航非常麻烦.我创建了一堆子文件夹,并将文件移动(单击并拖动)到相应的文件夹中.我没有更改名称空间或类名称. TFS将文件标记为[add](我不确定为什么).该解决方案已正确编译,因此我检入了文件.它也成功在本地运行.我去了Azure DevOps,将我的更改部署到我们的质量检查服务器,只是发现构建失败.我查看了构建信息,发现它有140多个CS0101错误:error CS0101: The namespace 'xxx.yyy.Data.Models' already contains a definition for 'ViewModelName'.

I had a problem with a Visual Studio 2019 check in. Repo was in TFS. I had two view model folders, one for the back-end secure site, and one for the public front-end site. It got to the point of over 60 view models in each folder which made navigating the Solution Explorer quite cumbersome. I created a bunch of sub-folders and moved (clicked and dragged) the files to their appropriate folder. I didn't change the name spaces or class names. TFS marked the files as [add] (I'm not sure why). The solution compiled correctly, so I checked my files in. It ran successfully locally as well. I went to Azure DevOps to deploy my changes to our QA server only to find out the build failed. I looked at the build info and it had over 140 CS0101 errors: error CS0101: The namespace 'xxx.yyy.Data.Models' already contains a definition for 'ViewModelName'.

推荐答案

因此,在进行了四处挖掘以确保没有重复之后,我想将所有文件复制回Models根文件夹,并且确定足够,他们仍然处于签入状态.因此,我删除了它们并签入了删除内容.瞧,构建成功了! TFS& Visual Studio在移动文件时有一些奇怪的行为.我应该做的是复制它们而不是移动它们,然后删除根文件夹中的文件.签入将被添加和删除,而不仅仅是添加"或重命名".我的意图是保留文件的历史记录.不行.

So after some digging around to make sure I didn't have duplicates, I thought to copy all of the files back to the root Models folders and sure enough, they were still checked in. So I deleted them and checked the deletes in. And voila, the build worked! TFS & Visual Studio have some odd behavior with moving files around. What I should have done is copy them instead of moving them, then delete the files in the root folder. The check in would have been adds and deletes, instead of just 'adds' aka 'renames'. My intention was to keep the history of the files. No Go.

这篇关于TFS/Visual Studio:CS0101:名称空间已经包含className的定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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