TFS/Visual Studio:CS0101:名称空间已经包含className的定义

编程入门 行业动态 更新时间:2024-10-24 20:12:16
本文介绍了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的定义

本文发布于:2023-11-09 10:24:08,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1572127.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:定义   名称   空间   Visual   TFS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!