Question

I have a VS2012 solution, containing 10 projects, and suddenly, I can no longer publish my Services project to any folder.

Publish to D Drive

When I try to publish to D:\temp, I get this error:

The expression "[System.IO.Path]::GetFullPath(obj\Release%25252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252528Prod%25252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252529\)" cannot be evaluated. The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters. C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web\Microsoft.Web.Publishing.targets

enter image description here

Huh ?

VS2012 (with update 4) seems to have taken my configuration name "Release(Prod)" and completely messed it up, causing the GetFullPath to produce too long a path name.

How the heck can I fix this ?

Out of desperation, I tried to build and publish the same project in VS2013 - and it had the same error message.

One of my colleagues said he'd seen the same thing, but had fixed it by removing the spaces from his configuration name. I tried this, which is why my configuration name is now "Release(Prod)" rather than "Release (Prod)", but it made no difference.

I did also open the file which this error is suggesting is the cause of the error: C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web\Microsoft.Web.Publishing.targets

..and noticed that there's something in there concerning the AnyCPU platform name. I have tried getting my Services project to use "AnyCPU" and "Any CPU" (depressed sigh) but neither seems to make any difference.

  <PropertyGroup Condition=" '$(IntermediateOutputPath)' == '' ">
    <IntermediateOutputPath Condition=" '$(PlatformName)' == 'AnyCPU' Or '$(PlatformName)' == ''">$(BaseIntermediateOutputPath)$(Configuration)\</IntermediateOutputPath>
    . . .
  </PropertyGroup>

Has anyone else seen this issue ?

(A little bit later..)

This is so odd (and frustrating).

My Solution has 5 configurations - the default Debug and Release ones, plus extra configurations for Test, PreProduction and Production environments.

enter image description here

If I select any of these three configurations containing brackets, I get this ridiculous "The specified path is too long" error, as VS2012 corrupts the pathname (as shown in my first screenshot above).

I can't help wondering... is this some kind of VS2012 bug, handling spaces or brackets in the configuration name ?

Was it helpful?

Solution

I can deploy to a path directly with (, (, )) in the Target Location on tyhe Connection tab when publishing to the file system (i.e. not building a path from the configuration name) - but that is not a solution to targeting different locations based on the Configuration.

If you want to keep special characters in the configuration name, but specify a path to the deployment folder that will not cause and issue this post might help: Visual Studio: How to properly build and specify the configurations and platforms for x64 and x86

Specifically play with the settings in here:

In the project properties page, select the various permutations of Debug/Release and x86/x64 in the solution dropdowns. Make sure the target processor is set correctly (it should be, but I found instances when they were not, probably because of my previous attempts). Also, set the output directory. That should be okay and automatic (/bin/x86/Debug, etc.). If not, fix.

Looking at what is actually seems to be going on is also potentially useful:

Looking at the numbers inserted:

  • %25 is an encoded %,
  • %28 is an encoded (
  • %29 is an encoded )

Looking at the path:

obj\Release%252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525***28***Prod%252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525***29***)

What I think is happening:

So that seems like a good clue that these are being URL or XML encoded. What appears to be happening is that the ( is being encoded as %28 and then the % is being recursively encoded as %25 - generating an infinite %252525252525252525....

A more interesting question is actually why it stops creating 25's from the %'s with this bug (both times it stops creating 25's at 214 characters including the % and the 28 / 29 - not a very interesting number).

Looking at the file C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web\Microsoft.Web.Publishing.targets you reference - it makes sense that these strings are being encoded for XML. I would say this is definitely a bug... I have no suggestions for a fix.

OTHER TIPS

Well, I'm going to accept Matthew's answer as the "Accepted Answer".
Thank you for your help.

This is a really odd problem though, and I'm amazed no one else has reported this elsewhere.

Summary of problem (in case Microsoft is interested, or if anyone tries to Google this issue in the coming years)

With a configuration name of "Release (Prod)", I could happily build my code, run it locally, but when I tried to publish it, even to a local drive, I'd get this message:

Cant publish

It's an odd exception, because the Build did create the "obj\Release (Prod)" folder, without any issues. It's just the Publish which seemed to be looking in the wrong place for it.

enter image description here

Following the advice given in this thread, today I attempted to create a new configuration, with the same settings, but without a space in the name: "Release(SecondProd)". Look what happens:

enter image description here

Interestingly, despite this error, it did create a new configuration with this name.

Anyway, I recreated a new configuration, called it ReleaseProduction, and it worked fine.

enter image description here

Of course, I needed to create new "web.config" Transformation for this name, as this doesn't get automatically copied when you create a new configuration based on an old one.

One last thought (just to confuse matters worse !)

When I posted this plea-for-help, the Services project in my Solution refused to publish to a local drive, but my web site would publish okay.

Today, two days since I last attempted a website Publish, I found that the website also now produces the same GetFullPath exception. Nothing's changed ! We use TFS, I have done a file compare with my project files today against two days ago, and they're identical !

It's a really bizarre bug in VS2012 & VS2013.

Btw, this solution & the projects in it, were originally a VS2010 project. They were upgraded to VS2012 over a year ago, but this Publish problem only started happening recently. I'm not sure if the problem is related to using upgraded VS projects.

Again, thanks for your help.

Now I have some Test, PreProd & Production configurations to recreate !

Maybe I'll grab a beer first..

Summarizing and completing Matthew's answer:

Cause: You have configurations with chars that require URI-encoding - in your case, '(' and ')'.

Workaround: Rename those configs.

What happens: Presumably web deploy URI-encodes the path, replacing % => %25, ( => %28, ) => %29. It does so over and over:

obj\Release(Prod)
obj\Release%28Prod%29
obj\Release%2528Prod%2529
obj\Release%252528Prod%252529
...

Until the path exceeds MAX_PATH=260.

I ran into the same thing and all though it does not resolve the issue I found that if I switch the solution configuration away from a build containing "(" or ")"

Then use the appropriate build in the publish dialog it will not error out.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top