Change local path of referenced project - c#

I'm building a set of plugin assemblies that I want to load in my main application. For that reason I have to search through a plugin directory named "plugins". I currently have my plugins attached to my main applications' solution with all projects in my solution and all projects are added as ProjectReference in the project file of the main application with CopyLocal set to true.
The problem is the I want to have the project reference outputs not copied to the OutputPath of the main application, but in a subfolder. I couldn't find any option to set something like this.

If I understand correctly this is what you want.
In the plugins project right click -> properties -> build -> output path
You can change the output path to anywhere you need and have the parent project reference the assemblies in that folder.

Related

BLL and DLL are not founded, when I move them somewhere except source repos(Visual Studio 2019)

I have 3-layer MVVM project, my solution folder, DLL folder and BLL folder are inside 'source > repos >' and project loads normally
But if I move BLL or DLL(or both) to some other folder, or Desktop for example, my project doesn't load correctly and file moved to Desktop defined as not founded in solution explorer
How could I fix it? I need put all this three project folders(DLL, BLL, View) to one folder, because I need to share it as one big project, but I can't, because any movement with files or folder finishes with error 'Files not founded'
Sadly can not send images here, in y question(
Thanks in advance for your answers!
Check for that in your project: is it in the references list? If it is, check that it's built for the same CPU type as your project, and that the Reference properties option "Copy Local" is set to true.
If it isn't, try adding it. If that works, try rebuilding. If it doesn't, then it's probably a Native Library, and you need to ensure that the DLL is either in the EXE folder, or in a folder on the current PATH that Windows uses to locate executables.
You Need to compile the DLL project into a dll file and then refer to the compiled dll file.
Or just use project references to add your DLL project and BLL project.

Output location of project

I was looking for the output of a project as a *.dll file to add it in References, but in bin folder there where Release and Debug folders.
Is there any difrence between the output.dlls?
Where is the useable output?
please explain the folders roles.
The folders correspond to your Solution Configurations, e.g. Debug or Release. You can specify custom configurations as well, and a folder would be created for it.
Instead of referencing the .DLL file directly by browsing to it, you should reference the project that defines the .DLL. If the project is not in your solution, you can add it by right-clicking on the solution title in the Solution Explorer and choose "Add" > "Existing project...".
This will allow Visual Studio to rebuild the .DLL in case you make changes, which you can now make without leaving your other project, and automatically reference the correct version, and also reference the configuration matching your project, i.e. if your project is run in Release, it will also use the release version of the .DLL.

Visual Studio: Library output path flexibility

Okay, here's the problem.
I have 2 projects. One is the main project (executable), the other one is a library.
MyNameSpace.Libraries.TheHolyMefLibrary
MyNameSpace.TheProduct
The default output path of both projects is bin\Debug\, so when I compile the main application, in the debug folder I can find both the Executable, as well as the library.
Now, I would like to have the following output:
bin\Debug\MyExecutable.exe
bin\Debug\plugins\TheHolyMefLibrary.dll
But when I change the output path of the library to bin\Debug\plugins\, the compiler still creates the following output
bin\Debug\MyExecutable.exe
bin\Debug\TheHolyMefLibrary.dll
How can I ensure that, no matter which project links to the library, it's always going to be in a subfolder of the output path from the main assembly, even in setup solutions?
To solve this I think the best way is to create a Post-build script where you move your linked assembly DLL to the plugins folder. You can find the post-build script editor when you right click the application project file and select Properties and then go to the Build Events tab. To create the build script you can use CMD commands like for example the MOVE command in your case or XCOPY.
Set the 'Copy Local' property of the referenced assembly to False to stop it being copied to your main project's bin folder.

Copy exe references to output folder

Say I create a visual studio class project A which is a wrapper around an exe. Getting the exe to be copied to the output directory is easy.
Now I create another project B that references the class A. Is there a way to set up project A such that project B will also copy the exe to the output directory when compiling? Like the exe to be a sort of "copy local dependency" of project A.
Thanks
Charles
Right, this is one way to do it. Will work if you have them both in the same solution in Visual Studio.
Add the reference Project A to Project B. (Or vice versa if I missunderstood you)
Right click the solution and select properties.
In Common properties you select Project dependencies.
In the project drop down select Project B and check Project A in "Depends on"-Checked listbox. (or vice versa)
Build project.
You should now have Project A.exe in Project B output folder.
To add an existing exe, which isn't inside your solution, you add the exe as a reference to your project.

C# plugin system design

So I am creating a plugin system for my app.
I have the following components:
1) Main Application
2) PluginInterface.dll
3) Plugin(s).dll
The problem now is that, when I create my plugins and compile them, there are more then just the Plugin.dll file. It has other required files in the Release directory such as the PluginInterface.dll that it uses, an xml configuration file, etc.
So how can I make it so that it is just a single dll file that user can drop into a plugin directory?
OR
do you think it's better to have the plugins be a folder? then, i have to scan all the folders for the right DLL...
The Managed Extensibility Framework is designed for plugin architectures. Before you go too far down your current path, check it out. It might serve you better.
When you compile your plug-in project, right-click on the references to the DLLs you are seeing and select properties. In the proepties set the "Copy Local" property to "false". Make sure that these DLLs are part of your main application, otherwise the code will fail when it can't find code that depends on it.
If you want to do that when compiling your solution you should create a post build event (Project Properties -> Build Events) to copy only the required files to the plugin directory.
You could also change the OutputPath of you project and use the option "Copy Local" to "false", but you'll not have the same level of control as by creating a build event.

Categories

Resources