开发者

Why does my project not get rebuilt and references in my unit tests not get updated when targeting x86?

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.


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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜