I've recently learned of the joys of compiling projects into dlls to use them in other projects! However, now I'm trying to streamline a process where I have two projects, one written in C# and the other in VB, where the C# project has dependencies on a dll compiled from the VB process.
What I'm hoping I can achieve:
- Have both of these projects viewable within the same VS project
Pull updates on the VB code from SVN and compile them into a dll located
in a folder within the project
Not have to update my references in the C# project as I am updating the same dll in the project.
Build the C# project whenever needed, without rebuilding the VB project
Can this be done?
Thanks!
Is this a VB.NET project? If so, you're in luck.
1) You cannot have a Visual Studio project that uses multiple languages (unless you count ASM in C/C++). However, a single Visual Studio solution can have multiple projects where each project uses a different language.
2) If the projects are C# and VB.NET (or F# or Managed C++ or any other language that produces a .NET assembly), there is little difference in the output assemblies of one versus the other. A C# project can reference an assembly built with VB.NET and vice-versa.
3) If the projects are in the same Visual Studio solution, you can use Project References instead of Assembly References. Project References make it so that one project depends on the output of another project in the same solution. You establish the project reference once (in VS2015: Right-click Project => Add => Reference... => Projects => select the project to reference). And then Visual Studio/msbuild automatically knows the correct order to build them (and whether or not to build them at all). It's even smart enough that if you change the output location of the referenced project, you don't need to do anything to the referencing project.
Related
As far as I know a C# project can be added to Unity3d in 2 forms. As DLL or uncompiled project.
What are the pros and cons of both? Will they work cross platform (Android/iOS/WinPhone)?
To compile as DLL - do I just use MonoDevelop or Visual Studio to new class library project and select .NET 3.5 and compile?
How do you add a uncompiled project to Unity3d?
Will they work Cross platform(Android/iOS/WinPhone)?
Yes. You can create a library project in Xamarin Studio/MonoDevelop/or Visual Studio. If you do not include platform-specific functions, it will be then cross platform.
To compile as DLL - Do I just use MonoDevelop or Visual Studio to new class library project and select .NET 3.5 and compile?
See this tutorial.
Well Well Well too many question in a single post. Try to answer one by one:
Unity Offical Docs provide much help:
Question
As far as I know a C# project can be added to Unity3d in 2 forms. As DLL or uncompiled project.
To compile as DLL - do I just use MonoDevelop or Visual Studio to new class library project and select .NET 3.5 and compile?
Usually, scripts are kept in a project as source files and compiled by
Unity whenever the source changes. However, it is also possible to
compile a script to a dynamically linked library (DLL) using an
external compiler. The resulting DLL can then be added to the project
and the classes it contains can be attached to objects just like
normal scripts.
It is generally much easier to work with scripts than DLLs in Unity.
However, you may have access to third party Mono code which is
supplied in the form of a DLL. When developing your own code, you may
be able to use compilers not supported by Unity (F#, for example) by
compiling the code to a DLL and adding it to your Unity project. Also,
you may want to supply Unity code without the source (for an Asset
Store product, say) and a DLL is an easy way to do this.
More
What are the pros and cons
About dll:
Pros
You can build DLLs separately.
It could be faster to re-build one DLL
Cons
Calling code from DLL is slower
It would be slower to re-build hole project with all DLLs
Function names are visible. It is easier to reverse code that uses
dynamic DLLs
You can find more on here, here and specially on Google, our best friend:)
How do you add a uncompiled project to Unity3d?
Ans: What do you mean by uncompiled project? You mean scripts? then it is usually Copy\Paste inside asset folder simply.
When you open your Unity project in an IDE (for example Visual Studio), it is a solution with two projects, one for game scripts and one for editor scripts. You can add more projects to the solution through your IDE of choice. In order for this to work, you need to set projects target framework to one that is compatible with Unity (which uses a subset of Mono), for example Unity 3.5 .net full Base Class Libraries. Unfortunately .NET PCL is not supported.
You can reference your (or third party) library in any of the projects as usual, just remember it also has to be compatible with Unity.
Wether your code will work on all the platforms actually depends on what you use. On platform specific limitations refer to http://docs.unity3d.com/Manual/PlatformSpecific.html.
I have a C++/CLI project that has a dependency on a .dll file. I've set up a post build step to copy the .dll to $(OutDir), which works great when building the project.
Now, I have a C# project that references the C++/CLI project, but the .dll isn't copied to the C# $(OutDir).
There must be a way to just reference a C++ project without having to explicitly know about it's dependencies, right? It feels really icky to have to have my C# project directly reference into my C++/CLI project's dll folder. On top of that, it seems very error prone. I have two C# .exe projects that are referencing the C++/CLI project, so I (or a team member) have to remember to update the references to both C# projects if we end up with a new .dll reference in the C++ project...
Maybe some way during the C++/CLI project build to copy to the "parent" or "master" project output directory? I'm a C++ n00b and only somewhat familiar with the msbuild process, so any thoughts or solutions are welcome!
Environment: Visual Studio 2013, C#, ASP.NET MVC
Question: For the projects that I create in Visual Studio that use C#, I would like to give others one compiled DLL as opposed to them having to add any extra DLL references themselves.
Example:
I have a project that is used for web services:
MyProjectWebServices.dll <-- this is what I would just like to hand out
Some3rdParty.dll
Another.dll
SomethingElse.dll
So, for the above 4 libraries that other projects need to reference as well since my original distributable library (MyProjectWebServices.dll) references them, is there a way to bundle the bottom 3 into just the first one?
I'm working on a project where I need to have both an executable so that the user can run a configuration interface and a DLL that can be embedded in other projects to use some of the other features. Is there a way to make Visual Studio produce both an executable and a DLL (as opposed to switching it manually every time)?
I agree with TJMonk15, but i think this should be explained explicitly. You should have two projects, one project that is a DLL, and one that is a normal project. The DLL project should have all your re-usable code. The normal project should be the application you are building, which will reference your re-usable DLL. This way you can build a framework in the DLL project that can be used for any of your future projects.
A good example of this is when you are making a game. Your game engine would be the DLL, and the game you are making would be the executable project. The executable project will contain all the non-reusable traits such as game GUIs and content.
Why wouldn't you put most of the code in one project (With an ouput of type Library) and then write an executable that referenes the DLL?
I have a WPF C# project that references a C++/CLI mixed mode project. I'm having trouble using the WPF project in Expression Blend 3. I'm new to Blend so perhaps this is obvious, but it won't display the xaml designer properly until it builds the project. In my case it complains that my custom commands are not "recognized or accessible" and the solution is to build the project in Blend. But I can't build the project because it references a C++/CLI mixed mode project which Blend won't load. The WPF project is pure C# it just happens to reference a C++/CLI mixed mode project but I'm not asking Blend to do anything with the mixed-mode assembly. How can I work around this problem?
Edit:
I was able to get it to build by removing the reference to the C++/CLI mixed mode project and replacing it with a reference to the actual assembly. However this is not ideal because in my past experience Visual Studio will not always be able to resolve the reference when switching between release and debug configurations.
I would consider setting up a second solution file. One to open in Blend and the other to open in Visual Studio. They would be nearly identical except that the blend version would reference the stated files in their built state. The VS version would reference the project as you prefer to VS.