1

For a visual C# project in microsoft visual studio IDE, what is the configuration settings to be used, so that it could generate both exe and dll outputs?

inquisitive
  • 1,558
  • 4
  • 16
  • 22
  • 3
    There's no such setting. – Darin Dimitrov Jun 13 '12 at 09:25
  • Sorry for my bad search for existing questions. I could see the same one asked in the below link: http://stackoverflow.com/questions/2466492/visual-studio-project-build-as-an-executable-and-a-dll As mentioned by Jared, how can we do the process of copying a exe to a dll? – inquisitive Jun 13 '12 at 09:34

3 Answers3

2

What you want can be easily achieved using nant. You have to create a simple xml file that is the script and that can be easily executed through a batch file. Once you created them then it's very easy no more manual work, every time when you need to build the project all you have to do is just execute the script.

Here is an excellent tutorial about nant.

VJAI
  • 32,167
  • 23
  • 102
  • 164
0

As Darin points out in comments, there is no setting to do this. However, you can achieve it via build events and batch scripts

  1. Create a pre-build event on the dll project to call a batch script
  2. In the batch, copy the csproj for the dll project
    • Modify the XML content of the copied csproj to change the output type to exe
    • Modify the output directory of the copied csproj
  3. Run this in Visual Studio

You will now get a copy of your csproj generated which outputs to exe. You can add the second csproj into visual studio and every time you build, it should synchronize the exe csproj and build it.

Some tips:

  • You can modify csproj's using Powershell. See here
  • You may want to modify all cs files in the copied csproj to be links
Community
  • 1
  • 1
Dr. Andrew Burnett-Thompson
  • 20,980
  • 8
  • 88
  • 178
0

I know this is an old question but it is possible to do a lot of things in the proj-files that is not possible in the user interface.

For this specific issue you just do like this:

  • Create a new project configuration, e.g. ReleaseExe
  • In the project's csprojfile you will find the following line

    <OutputType>Library</OutputType>
    
  • After that line add the following line

    <OutputType Condition="'$(Configuration)|$(Platform)' == 'ReleaseExe|AnyCPU'">Exe</OutputType>
    

Save, open the project and use batch build to build both the dll and exe

The nice thing is that you can use the Condition attibute on all tags in the project file. I have a project where I need to create two versions based on different 3rd party assemblies. To solve that I just add a condition to the reference tag.

<Reference Include="3rdParty" Condition="'$(Configuration)|$(Platform)' == 'Release1|AnyCPU'">
    <HintPath>Release1\3rdParty.dll</HintPath>
</Reference>
<Reference Include="3rdParty" Condition="'$(Configuration)|$(Platform)' == 'Release2|AnyCPU'">
    <HintPath>Release2\3rdParty.dll</HintPath>
</Reference>
adrianm
  • 14,468
  • 5
  • 55
  • 102