21

In Expression Blend 4, while compiling I get an error saying

The specified solution configuration “Debug|BNB” is invalid. Please specify a valid solution configuration using the Configuration and Platform properties (e.g. MSBuild.exe Solution.sln /p:Configuration=Debug /p:Platform=”Any CPU”) or leave those properties blank to use the default solution configuration.
Done building project “myproject.sln” — FAILED.
Build failed.

default
  • 11,485
  • 9
  • 66
  • 102
404Dreamer_ML
  • 890
  • 3
  • 14
  • 25
  • I had the same problem but with automated build in PowerShell. Removing the environment variable worked for me! – andrew.fox Sep 21 '16 at 12:56

4 Answers4

40

Background: At build-time the compiler (no matter if started from Expression Blend or Visual Studio) has to know what the target platform of your code, i.e. the system architecture like X86, 64bit etc.

The problem now is, that a system wide setting of an environment variable called "Platform" seems to override any setting of what Expression Blend uses as target platform, too.

I found some workarounds on other websites and will provide the possible solutions here. Trying one of the two suggestions should help:

  • Delete the conflicting environment variable "Platform" in "Control Panel -- System -- Advanced -- Environment Variables". Restart Blend and give it a try (maybe you have to restart your computer to make this work).
  • If this does not help: With the registry editor (Start -- Run -- "Regedit.exe") go to key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment and selected the key Platform. Delete the value BNB. If you do not find the specified key, try repacing "CurrentControlSet" with "ControlSet001", this worked for in one case, too. Then restart your computer.

Please give a comment which of the solutions worked.

EikeR
  • 416
  • 5
  • 5
  • 1
    I was following Scott Hanselman's MSBuild tutorial (http://www.hanselman.com/blog/HackParallelMSBuildsFromWithinTheVisualStudioIDE.aspx) and got the same error message. Deleting the environment variable (and rebooting) fixed it for me. – David McClelland Aug 04 '11 at 17:05
  • 7
    Deleting the "Platform" Environment Variable and then rebooting solved the problem for me. Apparently the variable is set to "BNB" by HP Easy Setup http://stackoverflow.com/questions/2507856/why-is-my-platform-environment-variable-defined-as-bnb – theisenp Jun 12 '12 at 20:21
  • THANK YOU!! This was driving me insane, I had some legacy code that was being built with command line tools and my HP laptop has the registry setting. Deleting it and rebooting solved my problem. I was able to fix a very obscure error. – Justin Aug 07 '12 at 19:51
  • We did option 2: removed the value for Platform and reboot. This worked for us and thank you! – workabyte Sep 09 '14 at 14:16
  • Platform was being set, but not the above two methods, and I couldn't find it anywhere else, so I added a SET PLATFORM= to my batch file to clear the X64 value, and the problem went away. – Robert Kerr Jan 01 '15 at 16:44
  • Thanks HP for yet another thing you've screwed up on my machine. And thanks @theisenp for helping me find out who to blame. :) – skiphoppy Oct 18 '16 at 20:54
4

I just removed the Platform from Environment variables and it worked.

Sergey K.
  • 24,894
  • 13
  • 106
  • 174
Robert
  • 41
  • 1
0

With Microsoft Visual Studio the following solution should work without restarting your computer. Run the command line (Windows Key + R, type cmd, hit enter) and type the respective commands for your project:

MSVC 2013: SET MSBUILD="C:\Program Files Path\MSBuild\12.0\Bin\msbuild.exe"

MSVC 2015: SET MSBUILD="C:\Program Files Path\MSBuild\14.0\Bin\msbuild.exe"

SET SOLUTION="your solution name.sln"
SET PROJECT="your target project name"
SET MS_PLAT="target platform"
; this could be x64 for 64 bit applications or Win32 for 32 bit applications
%MSBUILD% %SOLUTION% /t:%PROJECT% /p:Platform=%MS_PLAT%

For me, PLATFORM = BWS. Running the above script once fixed the problem permanently for my projects, without modifying or deleting PLATFORM.

TekuConcept
  • 1,264
  • 1
  • 11
  • 21
0

If still not work try to specify configuration and platform

for example

msbuild testproject.sln /p:Configuration=Debug /p:Platform="Any CPU"

This works for me.