VisualSVN - adding from separate Repos? - c#

I have a solution in Visual Studio 2010 that exists in one repo. I then want to add a project to this solution from a separate repo.
Ive tried right clicking on the solution in VS > Add existing project, but when it adds to the solution, all of the SVN bindings have disappeared in Visual Studio.
Is it possible to add a project from another repo into my current solution? Thanks.
BTW im using VisualSVN / TortoiseSVN.

You can use the svn:externals property to pull in part of a separate repository. Note that you lose the ability to commit atomically.

What you are trying to do violates some of the basic SVN usage principles. Each repository is supposed to be an integer and intact source of working code, so when another developer downloads the code he's got everything needed to work (except external dependencies, if any). You seem to be willing to force developers to make a filesystem puzzle of projects, that in the general case results in complicated check-outs from several repositories into several folders.
If you want to make a copy of a directory from another repository into your repository, I suggest you to do the following:
Checkout a copy of the project from the separate repository to a temporary directory
With Tortoise, export it into a subdirectory of your solution
Add it to VisualSVN, and then be prepared to commit all the files into your repo as a copy
Remember, once the separate repository is updated, updated won't be reflected on your repo. You'll have to make patches or better use merge command.

Related

re-using functions across projects in Unity and C#

I'm quite new to C# and Unity so have mercy on me. I'm using visual studio.
I have what seems like a pretty common problem. Which is - i want to use functions i write across several projects in unity. I don't want to have to go search for the code in some folder, copy paste it into the new project, or fiddle with symbolic links or use .dll's. These are all not great solutions to the problem. Can't i just somehow create a class I can access across all my projects? Custom namespace perhaps that is not project specific? that i can simply just call at the beginning of wherever i want to use my homemade scripts.
If you don't want to build a custom DLL and the headache that comes with maintaining its versioning alongside Unity releases, consider building an AssetPackage. You can right-click in one of your projects and export a bunch of scripts that you want to be re-used in other places together as a package. When you start a new project, just load that package into it by dragging and dropping it.
If you're using git for your projects, you could add the shared code into a separate repository and add them to your projects as a git submodule.
You have 2-3 things to consider in this situation:
Ease of deployment
Whether or not you will update that code
Ease of update, if you will update it
If you just want to bring it in once, then Erik's answer should be simple enough.
If you want to keep things as an updated library though, you will need another method.
Symbolic links as you mentioned would be the best, or DLLs. However, with this, you'd run the risk of breaking your other projects if you ever modify the common lib from inside your project.
Another option would be to have a separate VCS (git, svn, etc) inside your project for your common code. This way you can update if/when you want, you can roll-back if something breaks, and you can even fork your "common" code to make a project specific change.
Since OP mentioned it, in this case, OP could specifically use Git Submodules or simply add a second Git project and add that sub-Git to the parent's .gitignore file

Teamwork problem writing the code with colleagues in bitbucket

I am writing the code with my team by usin0 the Bitbucket service. The problem is the following:
Since yesterday, when I downloaded the last commit from our public repository I see all projects (folders) but in visual studio where I want to run the application the compiler tells me that some libraries, projects or references are missing. At the same time I see only one of four projects in visual studio(while it must be four). I've tried to rebuild the solution but this does not help.
When I asked one of my colleagues about the problem, he told me that this is a standard procedure and he will give me the access to all libraries and projects when the work will be finished.
My question is: Can I do something to got the access to all missing files?
P.S. I am the owner of Bitbucket repository
Check with your colleague their solution build before pushing new changes and all the dependencies / changes to packages.config and project files are pushed in.
Usually a clean and rebuild and a compare between project files will tell you what are the differences.
P.S. if you have a .gitignore file check that too, in case someone added something that is required to your project.

How to set up subversion to use updates to one project in multiple visual studio solutions

I'd like to create a c# project which I want to use in multiple solutions. All of these solutions are under version control (subverion).
Is there a way to set this project up so that I can have it in only one folder in the repository to which all changes from all the different solutions (which are under verison control as well) will be commited?
My goal is that no matter in which solution anyone on our team makes a change to this project all the other solutions/projects get the update.
Well, it already works in that way.
When you add a Project to a Solution in VisualStudio, you add a link to that Project, and do not create a copy.
In other words, if you have a:
SolutionA -> ProjectA, ProjectB, ProjectZ
SolutionB -> ProjectX, ProjectB, ProjectY
Whenever you make some changes in ProjectB (which is shared between those 2 solutions) those changes will be "visible" for both solutions.
What you should do is:
1 - Have a separate repo for this C# project.
2 - Include it in your other projects using svn:externals.
You can then commit changes to the C# project from any of the projects that are using it, and the next time any of the other projects does an SVN update, they will get the latest commits.

Updating classes used in multiple projects?

I have a few classes that are abstracted in a way that I can use them in multiple projects. I'm always working on these classes, optimizing, adding, etc. So when I optimize something in one of these classes, I then need to copy that new version into every project I remember using it. This isn't a very good way of doing it, but is there a better way?
Thanks
Put these base classes in a single project and share this project between your different solutions as an referenced class library. This way you will not have to copy / paste anything between projects or solutions and everything should always be up to date.
You could even set-up a local NuGet feed so you can use NuGet to retrieve this shared project as a reference in a well structured and managed way.
Instead of manually copying the updated classes to every project that uses them, create a Class Library project and reference the compiled file in every project that uses the classes. Organizing your classes like that will help you to follow the DRY ("Don't repeat yourself") principle.
If you need to reference files instead of compiled libraries, however, you can reference a file as a link so that multiple projects refer to the same file without copying it to each solution folder. To do that, right-click on your project, choose Add existing item..., browse to the .cs file, and choose Add as Link from the combobox in the right lower corner.
How about if you extract the classes into a separate project, and add a reference to this project in every project you are using?
It is a bad idea to copy paste file throughout the application. To avoid these repetitions you can either:
make a link, if the amount of file is really small . In the Solution browser of Visual Studio, right click, Add Existing file, chose your file and in the split button, choose Add as a link
create a separate project and reference this project wherever is is necessary if the amount of files not tiny.
Create a base-lib and build it to a "shared" location. Add a reference to it in you project. It will keep the other projects smaller and will be faster to build.

Question when adding a project to a Visual Studio solution

I created a brand new blank Visual Studio 2010 solution, and added an existing C# Project to it. I built the solution and it compiled correctly.
But when I go the solution folder, I see that the imported C# project is not physically in that folder. It seems it only references the project to wherever it is.
Is this intended? Should I even worry about this?
How can I create a physical import, meaning the project is copied to the solution folder?
How can I create a physical import, meaning the project is copied to the solution folder?
If you want to do this, copy the project to the solution (outside of VS), then add the local copy directly.
The default behavior allows you to share a project between two solutions. This is occasionally useful (if handled with care).
'How do I create a physical import?'
You don't - you're adding a project to the solution which will always result in referencing it in-place. In order to structure your solution you need to copy or move the existing project to the desired folder, created any desired Solution Folders to match the physical structure and then Add existing project as needs be.
The other alternative is to Add new project and then copy all of your project data over from the existing one but this will be prone to errors at some levels.
Adding an existing project always makes reference to the original. That makes sense in a lot of cases. If you want to use the project in a number of solutions and you want to make sure that they are always using the same version then you have the choice to either just reference the compiled library or have it available in each solution. If you do have it available in each solution then the risk is that you will make some mod of it in one solution that breaks the others. I am pretty good at doing this!
As mentioned already if you want to modify that project and don't mind if it gets out of sync with other versions of it then you need to copy it into your solution folder and then add it from there.
The version control software I use pretty much forces me to do that as it does not like code that is not located inside the solution tree.

Categories