Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
244 views
in Technique[技术] by (71.8m points)

azure devops - TFS / Visual Studio : CS0101: The namespace already contains a definition for className

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'.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...