48

I depend on a mixed-mode assembly which is compiled for x64. Because I do not want warnings in my build, all of the projects in my solution target x64 directly--they are not Any CPU.

To get my x64 unit tests to work properly, I find that I must manually change the Visual Studio unit test Default Processor Architecture to x64 every time I start Visual Studio. This is easy enough but tedious.

Is there a way to get VS to persist this setting so that I don't have to do it every time?

Andrew Miller
  • 481
  • 4
  • 3
  • Add a runsettings file to your solution and default the CPU. http://msdn.microsoft.com/en-us/library/jj635153.aspx – jessehouwing Feb 02 '14 at 17:23
  • 15
    Tried that. How can I get VS to recgonize the file automatically? If I have to select it using the "Select Test Settings File" every time, that isn't much better than having to set Default Processor Architecture every time. – Andrew Miller Feb 02 '14 at 18:23

3 Answers3

2

On Visual Studio 2013 I found that after setting "Default Process Architecture" to X64 I'll go and open "Options..." and close it with "OK", then the "Default Process Architecture" will preserved, at least for this one solution.

PeTeeR22r
  • 39
  • 3
0

UPDATE FOR VS2015:

To ensure your test projects run at x64 please do the following:

  • Select 'Build' and then 'Configuration Manager' from the toolbar
  • Set Platform to x64 for your test project
  • If x64 isn't present select 'New' and add x64. You can now select it

Then...

  • Right-click your test project from the solution explorer and select 'Properties'

  • Select the 'Build' tab on the left

  • Change the Target Platform to x64

Note that you might get BadImageFormatExceptions if you are targetting a different platform for your live project. For example if Project1 is x86 and your Project1Test is targetting x64 you will likely come across this issue. You'll need to make sure both are matching (or just select 'Any CPU').

Novastorm
  • 1,439
  • 3
  • 26
  • 40
  • This is actually just the precursor to the problem itself, VS will fail to find any tests from that x64 assembly until you set the default VS test processor architecture to x64 which is what the original question was trying to find an automated answer for. – laurencee Feb 25 '18 at 23:55
0

UPDATE FOR VS2017:

It seems that after opening the solution, when you click on the “Test Explorer” tab in Visual Studio, this rebuilds your tests. The “Run Test(s)” and “Debug Test(s)” menus become visible and enabled, as well as the checkbox next to previously selected “x64” option also gets restored.

The "Default Processor Architecture" menus option selected still seem to be cleared on close down of Visual Studio but the above action does seem re-select the previously selected option.

enter image description here

Mike
  • 827
  • 11
  • 27