This project has moved and is read-only. For the latest updates, please go here.

Problem importing project from existing code

Sep 1, 2011 at 1:16 PM

I'm eager to try PTVS with my current project, but when I attempt to use File > New > Project From Existing Code,  I get an error dialog saying

Files and folders cannot be:

- Empty strings

- System reserved names, including 'CON', 'AUX', 'PRN', 'COM1', or 'LPT2' - contain only'.'

- have any of the following characters: / ? : & \ * " < > | # %

After that, some, but not all, of the files and folders in my current project appear in the Solution Explorer. Entire sub-folders are missing, perhaps because there were troublesome files somewhere in them...?

I don't know of any files in my project that violate those rules. I'd be glad to change or omit them, but the dialog doesn't mention which of my files don't follow the rules, and with hundreds of files in the project it'd be too time-consuming to try to figure out which ones were causing the problem.

Is there any way to get VS to tell me what files it doesn't like?

Also, how does VS determine which files to include in the project? I have a number of .mako files, for example, that don't seem to be getting added by the import process, but I am able to add them manually.




Sep 1, 2011 at 1:32 PM

Not sure if this is relevant, but after a little more exploration I notice that my imported project seems to contain most of the subfolders immediately under the folder from which I imported the project, but most of them don't include any of my source files (but of course there are some in the actual folders).  I can't make out any pattern for what gets included and what doesn't -- in some places I get .pyc files in the project and other places I don't; sometimes I get .py files in subfolders and sometimes I don't. 

Thanks again for any help or insight anyone can offer!

Sep 1, 2011 at 2:28 PM

I'm having the same issue, jgarbers.  I tried importing a couple of existing code structures as new projects.  Both times, I saw the error you describe, but then it seemed to import my files.  Upon further investigation, not everything imported.  Stranger yet, when I closed VS and then re-started and opened the project, it was basically empty--all my dirs and files were missing in the project.

Sep 1, 2011 at 2:43 PM

I wonder how much of the New Project From Existing Code function is built in to Visual Studio, and how much of it is coming from PTVS? Is this a PTVS problem or a Visual Studio problem? I'd have to guess there are some rules or templates provided by PTVS, but the main engine for importing a project is in Visual Studio...?

Sep 1, 2011 at 2:53 PM

Actually, a lot of that code is our code, not VS's.  One of my test cases is to import the entire django-nonrel and django-appengine codebase, so I know that we should be able to handle hairy projects and if we aren't, it's a bug.

Would one of you mind opening up powershell, going to the root of your solution which you want to import, and doing

dir -Recurse > solution.txt


Then send solution.txt to me at along with the pyproj file we actually generated, and I think that will be enough to let me reproduce your issue.

Sep 1, 2011 at 3:02 PM

Thanks for the help, joxn.  I'm not with my code or VS today--I was trying to get this working yesterday.  Tomorrow, I'll be back in my office and can follow up as requested.  Thanks!

Sep 1, 2011 at 3:55 PM

joxn, I'll email you the files shortly -- thanks very much for your help!

Sep 2, 2011 at 5:33 PM
Edited Sep 2, 2011 at 5:40 PM

I am having the same issue as the folks above.  I am attempting to import 'trunk' from the UrbanSim project into a PTVS project file (see  I have the ankhsvn plugin installed to ideally have this all nicely integrated inside of VS2010.

I did get the error mentioned above, but it appeared to go ahead and import most if not all of the project, but its hard to tell given the number of modules and folders.  Then, after closing VS2010 and re-opening the project, I too get an empty project.  Everything was missing just as TroyWolf reported above.

EDIT: It appears that I opened the wrong .pyproj file, an empty one from an earlier attempt.  After opening the correct .pyproj file and a pretty lengthy opening process (~2minutes), I get what may or may not be a complete project: there are just too many files and folders to reasonably go through to verify.

I will email joxn w/ the requested files after posting this reply.

Thanks a lot for your help with this.

Sep 3, 2011 at 9:23 AM

It appears that VS thinks directories starting with a period (say, ".hg" or ".svn") are files with no names, which is why the error appears. This only matters for the root directory (of the project), since PTVS handles the recursion and doesn't break on these names. Temporarily renaming these folders while you import is something of a workaround.

The separate handling between the root folder (VS) and subfolders (PTVS) here is also why every single file is imported in the root of the project - there's no way for us to filter that one. (This should be the same behaviour for C# and VB, since we're hijacking their wizard rather than writing an entirely new one, though C# doesn't seem to dislike the ".svn" folder, so possibly we could be preventing this in PTVS somewhere?)

Sep 7, 2011 at 5:50 PM

After working with the project for a couple of days, I do believe that most everything was imported.  I cannot be 100% sure given the thousands of folders and modules, but everything seems to be there.  Thanks for the help with this.

Sep 9, 2011 at 5:36 PM

It also doesn't seem to like directories named 'bin', which don't get imported.

Has anyone else come across this?

Sep 9, 2011 at 5:36 PM
Edited Sep 9, 2011 at 5:37 PM


Sep 9, 2011 at 5:42 PM

asqui: It shouldn't be an issue w/ the name of the directory, rather it's probably the lack of bin having an  Does bin have other .py files that you expect to be imported or does it just have other files that you expect to be imported?  We're trying to figure out exactly how to change this feature to make it more useful.  Currently we're going to include all subdirectories, not just ones which include  Knowing what other files people think we should include in the project would be useful.  Thanks!

Sep 12, 2011 at 1:30 PM

dinov: In our case the bin/ directory contains python scripts, which typically use the modules contained in other directories that are peers to bin/.


Python scripts...

...which use the 'orm' module...


I think including all files in all directories (except for python project and visual studio solution files) would be a good idea.

Sep 12, 2011 at 6:39 PM

asqui: Great, in that case the current improvements should handle your scenario.