views:

39

answers:

1

I have a Console App created in VS 2010 targeting .NET 4.0. According to Microsoft (Rick Byers) AnyCPU is no longer the default for Console Apps because, in the Microsoft way, they feel like it is a better idea to default to x86. Also, the option to change the platform to AnyCPU, or x64 for that matter, does not seem to be available.

Now, I have this Console app that I am building, and I have a Class Library project where I am writing unit tests in NUnit (I practice TDD). So, the issue is that when I go to implement the code to make my tests pass they still fail. After a while I found that it is because (even when I do it from the solution level) when the project rebuilds it is not rebuilding the console app project. This causes the reference to not get updated in my unit tests which of course means my test is executing against old code and not the newly imlemented code. Big problem.

Currently, I am having to right-click the console app and select rebuild, then right-click the test project and select rebuild EVERY time before I run my tests. This is extremely annoying.

So, back to the question, how can I make VS2010 rebuild my Console App and update the reference in my class library automatically like it did in older versions of Visual Studio?

Please do not answer with "add a build event to do it." I would very much appreciate Visual Studio to just work because I don't want to have to remember that I need to "add a build event to do it" every time I create a new console app.

NOTE: So far, I have tried the following workaround at:

http://connect.microsoft.com/VisualStudio/feedback/details/455103/new-c-console-application-targets-x86-by-default

Which doesn't work for my unit test project. So I tried to delete the reference and re-add it from Visual Studio, and I get a dialog that says "Cannot add reference". So I reverted it back to the visual studio default template.

UPDATE: I logged this as a bug with Microsoft Connect here.

+1  A: 

Right click Solution and select Configuration Manager. Find Console App in list and check the "Build" checkbox. (Elusive to me how this is not default to be checked).

Solves my problem. Things now just work the way that I want.

If there is a better solution, or if someone knows a way to make it default to check this for me I would appreciate the answer.

Adam
It checked by default in my VS, have you tried to create new solution and new project and investigate wheter it is checked or not?
Restuta
@Restuta This is very strange. It does check it by default when I create a _new_ solution and add projects to it straight away. It does _NOT_ check it by default when I add a new console app project to my existing solution (previously a VS2008 solution upgraded to 2010)
Adam