可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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?
回答1:
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.
回答2:
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.
回答3:
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:
回答4:
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
回答5:
I had a similar issue in VS2013. I had no duplicates. The solution that worked for me was clearing the Visual Studio cache. http://blogs.msdn.com/b/willy-peter_schaub/archive/2010/09/15/if-you-have-problems-with-tfs-or-visual-studio-flush-the-user-cache-or-not.aspx
回答6:
I got the same error in VS2013, but only when I try to rebuild the project. Below how I solve the problem in my conditions, I hope that is also useful to other people.
Configuration:
- I have my typescript files in separate projects in the solution.
- Those projects were migrate for VS 2012.
Cause:
when I click on the error in Microsoft.Web.Publishing.targets files I discovered that the project was using the VS2012 version of those files. That is the projects where only partially migrated form VS2012 to VS2013.
Solution:
Open the typescript project (first unload project)
Search for:
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">12.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
- Comment the line VSToolsPath
- Save and close the file
Reload the project You can see a migration
screen from visual studio notifying you that the project was upgrade.
rebuild the project, now should work
回答7:
I just had the same problem and checking my .csproj file I found nothing wrong, no duplicate imports - nothing.
After stumbling 30 minutes I got it fixed by opening my .csproj file and rearranging tags in it.
Initially I moved them all to the top, but got an error message that OutputPath is not defined, then I moved all of them right below the where they were defined and everything worked. All of them except:
Most probably moving NuGet.targets from the bottom of the file was what actually fixed it. I have no idea, nor I want to waste more time.
Hope this helps someone.