Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS2012 $(exists) only accepts scalar values

Okay, this is more of a build error than a programming error. I have never had much reason to get my hands dirty with builds, so this error is baffling me.

I have tried googling this error with little results, the responses are either nonexistent, incomprehensible or not applicable.

The error is:

The "exists" function only accepts a scalar value, but its argument 
"$(PackageSourceManifest)" evaluates to "[same path];[same path]" which is not a 
scalar value. C:\Program Files(x86)\MSBuild\Microsoft\VisualStudio\
                                   v10.0\Web\Microsoft.Web.Publishing.targets

Anyway, I dug into Microsoft.Web.Publishing.targets and I found the line where it is erroring out. I have verbose builds on where I was attempting to see if I could find anything that stuck out to me that I could fix.

Nothing.

I have googled how to change Package Source Manifests, I have looked in Build Properties, I have searched for a source manifest or even something that says source manifest, nothing. Maybe I am looking too hard or maybe I just don't know what to look for.

Any ideas on how to fix this and what caused this?

like image 939
Madeline Avatar asked Aug 01 '13 23:08

Madeline


4 Answers

Open your .csproj file and look for any duplicated import tag.

In my case the .csproj had two lines like this:

<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio \v10.0\WebApplications\Microsoft.WebApplication.targets" /> 

Remove one of them fixed the problem.

like image 162
giacomelli Avatar answered Oct 02 '22 12:10

giacomelli


Had the same issue in VS 2012 -

Error   48  04115: The "exists" function only accepts a scalar value, but its argument "@(_UnmanagedRegistrationCache)" evaluates to "obj\TheQueueData.sqlproj.UnmanagedRegistration.cache;obj\TheQueueData.sqlproj.UnmanagedRegistration.cache" which is not a scalar value.   C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets  1091    7   TheQueueData 

Closing and re-opening the solution did the trick for me.

like image 31
Moiz Tankiwala Avatar answered Oct 02 '22 11:10

Moiz Tankiwala


I had the same issue, due to improper import of $MSBuildExtensionsPath32$. It's obvious that v10.0 is for VS2010 whereas you're on VS2012 (v11.0).

Therefore, change your import to:

<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v11.0\WebApplications\Microsoft.WebApplication.targets" />

For other, if you have VS2013 (v12.0), you can change it to:

<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v12.0\WebApplications\Microsoft.WebApplication.targets" />

Note: if your remove this line like @giacomelli suggested, you'll not be able to use define your custom target file.

From MSDN : MSBuildExtensionsPath32

http://msdn.microsoft.com/en-us/library/ms164309.aspx

Introduced in the .NET Framework 4: there is no difference between the default values of MSBuildExtensionsPath and MSBuildExtensionsPath32. You can set the environment variable MSBUILDLEGACYEXTENSIONSPATH to a non-null value to enable the behavior of the default value of MSBuildExtensionsPath in earlier versions. In the .NET Framework 3.5 and earlier, the default value of MSBuildExtensionsPath points to the path of the MSBuild subfolder under the \Program Files\ or \Program Files (x86) folder, depending on the bitness of the current process. For example, for a 32-bit process on a 64-bit machine, this property points to the \Program Files (x86) folder. For a 64-bit process on a 64-bit machine, this property points to the \Program Files folder. Do not include the final backslash on this property. This location is a useful place to put custom target files. For example, your target files could be installed at \Program Files\MSBuild\MyFiles\Northwind.targets and then imported in project files by using this XML code:

like image 22
Dio Phung Avatar answered Oct 02 '22 11:10

Dio Phung


I think this happened to me when I a tried to Web Publish a project in VS2012 that had originally been a VS2010 project. So recreating the project in VS2012 is a way to cure it. Or as @Giacomelli mentions, deleting the reference to the v10.0 targets. Note that V10.0 = VS2010 and v11.0= VS2012

like image 43
Chris F Carroll Avatar answered Oct 02 '22 11:10

Chris F Carroll