Visual Studio Project References inside solution - visual-studio

What is the best way to reference a project inside solution.
I added references via Add Reference --> Projects. However it links to either release DLL or Debug dll.
I want to have project itself in the reference, when we compile the projects, all the references projects must be compiled (through dependencies).
How to do this?

If you want to reference a project itself, and NOT a DLL/assembly (from the Browse tab in the Add Reference dialog), then you should add the project you want to reference to the Solution (Add... Existing Project). Once it's in the Solution, the Add Reference dialog will let you reference one project in the solution from another project in the solution (via the Projects tab in the Add Reference dialog).

Related

Plugins and Sandboxing - Add reference to another project in solution

I have a plugin assembly I have registered to D365 CDS(cloud) and it runs fine.
I want to reference and use some classes in a separate project included in my solution in Visual Studio.
Adding the project as a reference will give File Not Found exceptions. I am able to add the individual classes using the Add Existing Item - Add Link option, but I would like to do it as a whole project reference instead of individual links. Is that possible without using ILMerge and how would I accomplish that?
As I mentioned in my comment, I create a SharedProject in Visual Studio (2017). I put all my Business Logic into this Project (or Projects).
Then I can have a "Workflow" and a "UnitTest" project that each refer to that Shared Project.
More Info

How to detect if the project reference is existing project or dll itself?

I'm interested how can I determine within Visual Studio (possibly from a given project reference properties window) if a project reference was included as an existing project or targeted as a dll itself?
This becomes handy when there are unresolved reference that I have to remove and include again, so I could know what kind of reference to search for.

Visual Studio 2010: Dependency of Managed project on Native one

It is not possible to "Add reference" of managed project on native.
I have found here that this is possible via "Add item" - reference to dll. But in such case rebuild of dependent projects will not happen.
If I add dependency directly in project files via <ProjectReference> item group item, VS shows dependent project in References, but with Exclamation mark (!).
How to add reference of managed project on native one smoothly?
Thanks!
If you are trying to capture inter-project build dependencies at the solution level where those projects can't actually reference each other, you can set up explicit dependencies inside Visual Studio by right-clicking on the project in question and choosing "Project Dependencies...".
You can explicitly specify the dependencies here (but implicit dependencies will already be greyed out). Adding dependencies in this way will alter one or more ProjectDependencies sections in the solution (.sln) file so that building it from either devenv.exe or msbuild.exe will ensure correct build order.

Make Visual Studio not to compile any projects

Is it possible to tell VS not to recompile some projects every time and use already compiled dll-s instead?
You can exclude any project from building in Configuration manager. Just unselect desired projects in Build column. You still will be able to debug those projects.
Instead of project references, you can add the compiled DLLs as references.
Any such referenced project will not rebuild if not changed.
However, since the references will now be to DLLs, you need some strategy to keep them synchronized and up to date with your code.
As I understood your question, you have a solution with multiple projects and you seem to have dependency of some of them on some other.
VS will always compile all the "loaded" projects. But when you add a reference to a project, add it directly to a (preferred) DLL assembly file, and not to one of the projects. This way the other project will be compiled but you are referencing the same DLL assembly over and over. Since if you reference the project, the output of the project is always what you reference actually.

How can I force Visual Studio to reference an assembly without using its version?

I have a VC++ project and I need to add a reference to a managed dll. This dll has a version number which changes every build. When I add it to my project, its version is saved and if I replace it with another one (with a different version number) the project cannot compile because it doesn't find the dll with the version previously saved.
Is there a way to add a reference without a specific version?
Thank you for your help
The C# IDE has the "Specific Version" property for a reference but the C++/CLI build system doesn't support that. There is a workaround, you can use the #using directive in source code to load an assembly reference. This by design cannot check the assembly version of the reference assembly. Normally that's a problem but not in your case. The MSDN page is here.
Note: I don't know whether this works with C++ projects -- we have C# code that references C++, but we haven't done the other way around. But just in case it's easy, I'll offer this:
With C#-to-C# references, normally you would make sure both projects are in the same solution, and then add a reference using the "Projects" tab of the Add Reference dialog (not the "Browse" tab). This way, the build system has a reference to the project in the solution (which knows its own current version number), rather than having a reference to the filename+version; and then it can cope with version number changes just fine.

Resources