开发者

Working around "one executable per project" in Visual C# for many small test programs

开发者 https://www.devze.com 2022-12-30 18:09 出处:网络
When working with Visual Studio in general (or Visual C# Express in my particular case), it looks like each project can be configured to produce only one output - e.g. a single executable or a library

When working with Visual Studio in general (or Visual C# Express in my particular case), it looks like each project can be configured to produce only one output - e.g. a single executable or a library.

I'm working on a project that consists of a shared library and a few application, and I already have one project in my solution for each of those. However, during development I find it useful to write small example programs that can run one small subsystem in isolation (at a level that doesn't belong in the unit tests).

Is there a good way to handle this in Visual Studio? I'd like to avoid adding several dozen separate projects to my solution for each small test program I write, especially when these programs will typically be less than 100 lines of code. I'm hoping to find something that lets me continue to work in Visual Studio and use its build system (rather than moving to something like NAnt).

I开发者_如何学C could foresee the answer being something like:

  • A way of setting this up in Visual Studio that I haven't found yet
  • A GUI like NUnit's graphical runner that searches an assembly for classes with defined Main() functions that you can select and run
  • A command line tool that lets you specify an assembly and a class with a Main function to run


Rather than write small test programs, consider writing unit tests. That leads you directly in to Test Driven Development.

You can have as many unit tests in a test project as you need.


I find myself using LinqPad in this kind of situation. I can link to the application exe/dlls and then run test code that references the project/solution components.

I find it far easier using mess around using that to write a little bit of code can reference the project but which doesn't have to be part of the permanent code base.


One project - one output. Simple. No way around it.

Use unit tests for snippet compilation.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号