160

The visual studio 2012 on my PC get the following error message when preview in the "Public Web". I need to restart VS to get rid of the error message.

Invoke build failed due to exception 'Specified condition "$(PackageAsSingleFile)" evaluates to "" instead of a boolean. C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web\Microsoft.Web.Publishing.targets'

What caused the error?

ca9163d9
  • 27,283
  • 64
  • 210
  • 413

5 Answers5

217

I'm not sure what causes it, but restarting VS 2012 fixed it for me.

Rusty Divine
  • 3,462
  • 1
  • 21
  • 15
  • mucking with the web deploy settings caused this for me, and restarting VS was also the fix. – CodeGrue Apr 09 '13 at 18:32
  • @CodeGrue I was doing the same, went to publish, got this, restarted VS and magic works. – Chris Marisic Jun 03 '13 at 18:00
  • Restarting VS 2012 is not a way. After 3 publishing this error show again. – ms_devel Sep 24 '13 at 01:46
  • 4
    Anyone has a more structural solution to this? Restarting works, but I keep getting this error occasionally.. – Pbirkoff Jan 29 '14 at 13:27
  • 5
    I seemed to get this after adding a nuget package, maybe a point for investigation? – Thomas Harris May 23 '14 at 08:36
  • @ThomasHarris - do you know which package(s) you just added? – Rusty Divine May 23 '14 at 12:52
  • 5
    I started to debug a program in VS2013 (Update 2), then cancelled with Ctrl + Break. From that point, I started getting this error whenever I attempted to build, publish or debug the project again. Restarting VS2013 resolved it. – Whit Waldo May 24 '14 at 19:33
  • @RustyDivine I'm pretty sure it was the Microsoft BCL nugets. – Thomas Harris May 24 '14 at 20:49
  • I notice I generally get this when I try to do the "web publish preview". – emragins Aug 18 '14 at 22:37
  • 2
    This seems to be an issue with NuGet, when updating or uninstalling packages. I'm running VS2013 Ultimate, but I'm running so many plugins and addons that debugging becomes a war of attrition; especially since restarting VS solves the problem. For issue research purposes, this occured for me when uninstalling Nuget Package TinyMCE.MVC.JQuery and updating to TinyMCE4.MVC.JQuery. – Apache Oct 04 '14 at 22:11
  • I am also having this problem but I get it when reinstalling NuGet packages. Restarting VS has no effect, but deleting the .suo files did fix the problem for me however. – bikeman868 Mar 22 '17 at 20:42
  • This also worked in VS2017: After I got this error due to a known issue with A dependency, switching to a known working git branch did not resolve it until restarting VS. – packoman Oct 08 '18 at 09:50
46

Restarting VS usually helps, but when it doesn't - try deleting .user and .suo files, as per this suggestion: https://stackoverflow.com/a/16223645/913845

This does not always work, however if you skip "Preview Deployment" it is less likely to fail.

Probably it's the solution to the entire class of evaluates to "" instead of a boolean. Visual Studio problems. Something for VS team at MS too look at?

Community
  • 1
  • 1
Zar Shardan
  • 5,675
  • 2
  • 39
  • 37
11

I've found a very very weird (and working) workaround for this type of deploy issues, if you have tried closing & opening VS with no luck, try to close all open document prior to the publish process. weird huh? :)

so the complete fix-it guide for this type of issues would be like the following:

  1. Try "Clean" then rebuild
  2. If it's still not publishing, try closing & reopening your project again
  3. Still no luck? try closing VisualStudio but this time delete all the *.user & *.suo files, then open up your solution again and give it a try.
  4. Finally if all these steps are not working, try my newest trick, close all the opened document and give it a try

let me know if this has helped you :)

Mohammed Swillam
  • 9,119
  • 4
  • 36
  • 47
1

One common scenario that also raises that error is when you have files referenced on your solution that are missing.

So excluding those from the solution will fix it.

Hugo Hilário
  • 2,848
  • 2
  • 27
  • 43
-4

You need to run Visual Studio "As Administrator". The path specified requires administrative authority for writing.