سؤال

I have two projects - one is a test one, other is the final version. I know there is a possibility to put shared code into a library, but I want that compiled result will be a single file, without any additional DLLs.

هل كانت مفيدة؟

المحلول 3

You can "link" a code file between two or more projects. Just Right click your project, choose Add -> Existing item, and then click the down arrow next to the Add button:

In my experience linking is simpler than creating a library. Linked code results in a single executable with a single version.

نصائح أخرى

You can make use of ILMerge which will merge number of .Net assemblies to a single assembly.

You should usually be able to add the same source code file to more than one project. In C#, for example, projects can contain links to files that are stored in other locations and that will be included in the compilation like any other files.

  • In Visual Studio 2012, for example, the selected answer to this question points out that you can drag files into a project while pressing the Alt key to create a link.
  • This article points out that a respective option is found in the Open file dialog when adding an existing file in some versions of Visual Studio.
  • In SharpDevelop 4, you can use Add -> Existing item from the project (or a project folder's) context menu to select an existing file to add to the project; if that file is outside of the folder hierarchy of your project; SharpDevelop will ask you whether you want to copy the file or just create a link to it.
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top