Visual Studio & Source Control: how to have common code?

I want to have common code (code library, controls, utilities, helper classes, etc.) in Visual Studio. I do not mean general assemblies, I mean general code (i.e. I want to send one assembly with my application, the executable assembly).

The technique in other development environments is to have common source code in the path on my machine, and the IDE provides a list of paths for finding code files.

Visual Studio does not support code search paths.

The backup fix is ​​to copy the source code over and over to each project. But then, in order to save them as one version, they are separated in the source control. This works well when the source code provider is Microsoft Visual SourceSafe - which supports shared files.

But other version control products (CVS, Subversion, Microsoft Team Foundation Source Save Server, SVN) do not support shared files.

So, how does everyone else avoid delivering the DLL with their executable?


Update 1

This is a single file deployment problem. ClickOnce generates 18 files in 3 folders (i.e. more than one file)

+2
source share
4 answers

I could offer two solutions:

  • Visual Studio allows you to add a link to a file. Select "Add Existing Item", select the file and click the arrow next to the "Add" button. A popup will appear and you should select "Add as link." Now you can save your shared code in one place (folder).

enter image description here

  1. Compile your common code in reusable builds and use them in your projects. Use ILMerge to merge all assemblies into one during deployment. I personally prefer this option.
+3
source

In my work, we begin to solve this problem using Subversion external folders . You just need to put the "external" property in the root yor folder (or any folder), for example:

  ExternalLib https: // yourrepo / SharedLibs / trunk

When updating the project, the ExternalLib folder is created and filled with the contents of the repo. Any commit will be reflected in the corresponding repo.

So, you can make your backup solution for hacking with SVN too =)

+1
source

We are using ClickOnce deployment, which was very reliable. With ClickOnce, there is conceptually one object, an application, although many files (including DLLS) are loaded, although they are hidden to the user. Then the common code is processed using common projects.

But if you only need one file physically, ClickOnce will not work for you ...

0
source

perhaps consider sharing assemblies and using a tool like ILMerge during the build process to combine them all with one build of errors.

0
source

Source: https://habr.com/ru/post/1336253/


All Articles