0

I have a wpf application, how do I force creating a corresponding .dll on build?

Example: Project name is "MyWPFproject"

On build it shall create "MyWPFproject.dll" in bin\Debug

How to accomplish this?

Edit because of many similar answers: I know how to add/reference "external" libraries/dll files. I am fully aware of this. Please re-read the question, I want the BUILD-Process to create a .dll besides the .exe in bin/Debug

Best_Where_Gives
  • 481
  • 2
  • 22
  • 1
    Have you added a reference to the class library project from within the solution? If so it should automatically copy it to the bin\Debug or bin\Release – ganeshran Jan 16 '17 at 13:07
  • @ganeshran: How am I able to reference the class library, if it does not get generated in the first place? -mm8: Yes, thats true. And now I want the Solution to create a .dll of the project as well – Best_Where_Gives Jan 16 '17 at 13:13
  • Do you actually have a class library, i.e. another project that you reference from your WPF application project? Othwerwise there is no .dll to build. The executable application itself is built as an .exe. – mm8 Jan 16 '17 at 13:14
  • Just to clarify, - you have a WPF application which references a DLL which is built by another class library project in the same solution? If this is correct then you can add a reference to the project (not the dll file itself). This will be shown in the solution section in the Add Reference dialog box. – ganeshran Jan 16 '17 at 13:16
  • This is the Solution menu of the Add Reference Dialog box. http://i.imgur.com/eBDA94w.png Your class library needs to be in the same solution as your WPF application. – ganeshran Jan 16 '17 at 13:18
  • mm8&ganeshran: No, it must be the same project. I do reference other dll´s, yes, and I am aware of how this works, and it does work. If I create the dll by changing the output type to 'class library' and copy it to bin/debug, then it works like a charm. But as soon as I check in, the dll does not get created and thus the program is not working anymore – Best_Where_Gives Jan 16 '17 at 13:19
  • So you're trying to build a WPF executable application to a DLL? Have you checked in the csproj changes after changing output type? When you say it doesn't work after check in, do you mean on a dev build? Is this build generated by a CI Server? – ganeshran Jan 16 '17 at 13:28
  • I am building it to an executable, but I need the .dll as well. Yes, I mean on a dev build and it´s not generated by ci-server, I have to trigger in manually. – Best_Where_Gives Jan 16 '17 at 13:34

3 Answers3

2

It's not really necessary to convert the .exe to a .dll as an .exe works fine as an assembly reference:

Converting .exe project to class library

If you still want to create a copy of your .exe for some reason, you could do this in a post-build event of the project (Project->Properties->Build-Events in Visual Studio):

xcopy /y /f "$(TargetPath)" "$(TargetDir)$(ProjectName).dll"

enter image description here

Note that you may have to run Visual Studo as an administrator for this to work. Right-click and choose "Run as administrator" when you open it.

Community
  • 1
  • 1
mm8
  • 163,881
  • 10
  • 57
  • 88
0

There is and it is not reliant on post construct occasions.

Add the record to your project, then in the document properties select under "Duplicate to Output Directory" either "Duplicate Always" or "Duplicate if Newer".

0

For now, I am using the following work-around: I add the .dll file of itself into the lib-directory as well, instead of trying to force the project/solution to build it into bin/debug and change the directory accordingly. I´m still not quite happy with this solution though..

Best_Where_Gives
  • 481
  • 2
  • 22
  • Check this question - http://stackoverflow.com/questions/6866554/changing-csproj-outputtype-based-on-project-configuration This alters your project's output type based on the configuration. This configuration can be altered from msbuild – ganeshran Jan 16 '17 at 13:49
  • You could use a post-build event command as I have suggested in my answer. – mm8 Jan 16 '17 at 13:53