I have a big solution with about 250 projects.
I need to change the prefix of solution (my company name) from "X" to "Y".
Of course some of the projects' names start with the prefix - X.Utilties, X.Dal...
Means I should change project namespaces, assemblies, folders and references and even injection (IoC).
What is the best and safest easy way to do it?
I´d suggest getting the trial version of Resharper and using the available refactoring tools to change all namespaces.
From the top of my head you´d do it this way:
Manually edit your project files to have the new name (or do it with find/replace)
Reopen the solution in visual studio
Right click on the solution > Refactor > Adjust namespaces
Related
My situation:
I have a solution A with hundreds of projects,
Some of projects are class libraries and are referenced from other projects.
Now I want to create a new solution B which will consist of subset of projects of solution A. I start by adding the first pre-existing project into this new solution B. This project is referencing couple of class libraries from solution A. Therefore it is logical that these libraries cannot be found and I cannot build. Of course I could add all the referenced projects manually into the new solution B but that would take quite a long time, considering the total amount of projects that I need to add.
Is there some built in Visual Studio feature that can take care of this on my behalf? I.e. I will be offered an opportunity to import all the referenced projects at once and the B.sln file will be updated automatically.
I also have a ReSharper extension but I couldn't find such feature in there as well.
EDIT:
Some more detail on what I am trying to achieve. A.sln has lots of application projects and literally hundreds of class libraries. I want to create a new B.sln for one particular application project from A.sln and only add the class libraries that it is referencing, directly or indirectly... But the dependencies can go up to 15 levels deep so manually removing projects from original A.sln to create B.sln is really not suitable for me as I would have to carefully consider each one of the projects that I would be manually removing from the original sln file, subsequently reviewing the csproj files to find whether the application I am interested in does not indirectly depends on them via one of its direct references.
Copy paste your current solution file and start with it. Open it in new Visual Studio Instance. Remove your projects one by one. Instead of adding new projects, removing unnecessary ones will be more easy for you. As far as I know there is no such feature in Visual Studio as you want.
Removing will be more easy since projects are already there. Do not use Visual Studio to remove project but open sln file in suitable programmers notepad. Your projects are added to sln file as below lines.
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Example.Integration.App1", "..\Example.Integration\Example.Integration.App1\Example.Integration.App1.csproj", "{E3977144-AFBA-451D-894C-1F89AA008041}"
EndProject
Removing such lines will be more easy if your projects has naming convention.
The best way to port references from an existing project that I've found is to generate a template for that project.
On the File menu, click Export Template. The Export Template wizard opens.
Choose project template and move through the wizard
Click Finish. Your project is exported into a .zip file and placed in the specified output location, and, if selected, imported into Visual Studio.
Now, when you setup a new project for solution B. You'll be able to choose the project template from A and all the file structure/references are preserved.
Ref: http://msdn.microsoft.com/en-us/library/vstudio/xkh1wxd8%28v=vs.100%29.aspx
I'm working on a project that references a dll that has been obfuscated. The dll has many namespaces and classes that are single letters.
My issue is that many times while typing, Resharper will suggest classes from this assembly, e.g. if I am typing 'Report' it will suggest 'r.e.p' from this other assembly.
Is there a way I can get Resharper to ignore this one particular assembly for intellisense options?
Thanks
It is not possible now - there is the same feature request.
If your source code is located under a single parent directory, Resharper allows you to exclude it:
Goto Resharper -> Options, Settings, then press the 'advanced button'
There you can enter the directory and/or files to exclude from the solution wide analysis.
Go to Resharper > Options > Intellisense. Just look at it if you can find what you are looking for.
Need to add two same name .csproj class libraries in my solution.Have two project but unfortunately those project class libraries names are same,like: Hello.csproj.I try to add existing project on solution then show me error
http://blogs.msdn.com/b/ansonh/archive/2006/09/27/774692.aspx
from above url I learned how to use same namespace dll on same project ,but I need help how to use same classlibraries on a solution
if have any query please ask,thanks in advanced.
Note:ok people want to know the reason,i have two project on Autocat 2005 and 2010,now want to merge those project on one solution,2010 update base on 2005 so class libraries are same,but i need to use both of them.So problem arise and seeking help.
You can have projects with the same name as long as they are already created in different folders and they are in different solution folders. If the projects are already created, do this to add them to your solution:
Add your first project to the solution.
In Solution Explorer window, right click your solution and select Add->New Solution Folder
Give a name to the newly created folder.
Right click the folder and select Add->Existing Project
Navigate to your second project and double-click the .csproj file.
You're done.
If you really must do this, then ensure the second project has a different name, and then change the namespaces of the classes in the second project (normally the project name comprises the first part of the namespace - just change that part). The classes will still be identical internally, but because they have a different namespace they will be distinct entities. This will lead to very smelly code though when you start mixing them up in the ClientApp - to avoid confusion make sure you always refer to them by their full namespace (i.e. do not have a using xyz.myclassname; statement at the top of the class file that uses them).
Maybe you want to run two (almost identical) instances of the same service or something, but as mentioned it is hard to think of a genuine reason why you would need to do this. If you are looking to have two identical looking instances but different implementation then you will want to use interfaces instead.
Edit: Visual Studio will not allow you to have two identically named projects, and you are playing crazy games if you change a project name but don't change its project GUID (in the .proj file and the .sln file).
The simplest thing for you to do here is to create a new empty project in the solution explorer, right click on it and Open folder in Explorer, then copy the class files from the original project to the new one, then back in the solution explorer choose Show all files (little button at the top of the solution explorer), then select the newly added files under the new project, right click, Add to project. (These menu options are from memory, they should be roughly right).
I just opened a solution from TFS using Visual Studio 2010. The solution contains more than 100 projects (if up to me, it would probably be less than 5) and many of them happen to miss a reference (to Unity dll's).
Is there any way to simplify the fixing of these references? Now I have to delete and re-add all of them manually. Hassle.
Any suggestions would be appreciated.
To fix the problem you need to find out from where it tries to load the files. You can do so looking in the project csproj file. You either have newer (or different) versions of the assemblys installed or you have a different file and folder structure. You need to recreate the file and folder structure that has been used in that project or rewrite the csproj file to the new location.
For the future you might want to change how 3rd party references are handled. I have good experiences using this approach: Define a ThirdPartyLibraries Folder where all those libraries go and check it in. It should be in the solution folder. Everybody has to put 3rd party libs in there from now on and use them instead.
Might want to check out resharper, it might do what you need for references. I know it helps optimize and identify references in classes, not sure at the project level. Resharper has a 30 day trial
You can add all those binaries in to Binaries folder and add in to your TFS.
Now add the binaries as existing item in your solution items, so that when you open the solution it fetches all the solution items as well.
Make sure the references are added from the binaries folder.
If the location of the referenced assembly has changed, then it is relative simple to do a Find and Replace in files on the .csproj files to replace the broken reference with the correct one.
I made arrangement in my solution. I made seperation of projects and reorder directories. Now my namespaces are messed up. Is there any tool that will arrange the namespaces according to the position of the file in the project?
For example, if a cs file is in Printers/Pdf directory under MyProj project, I would like the namespace of the classes in the file will be MyProj.Printers.Pdf.
EDIT: I am looking for free tool if possible.
Resharper can do this, though it's commercial. But there is a trial version.
Resharper > Right click on the project > Refactor Menu > Adjust Namespaces. This will re-arrange all namespaces according to folder structure, as it should be.
Resharper can do this as well as update the using statements in all files which use those classes.
Resharper is the best option and is well worth the money. If you have paid the costs for Visual Studio, a Resharper license cost will feel like pennies.
As for free options, I think a project wide, find & replace might be your best bet. You could find what the incorrect namespace is, then folder by folder find it and replace it with the correct one. If you just moved it to a different project, you could just search for...
namespace MyOldProject.
and replace it with...
namespace MyNewProject.
This is assuming you kept directory structures.