How can I add an existing folder structure to my visual studio project (python tools)?
If nothing else works, you could add the files and folders manually in the .pyproj
-file. The format is simple:
<ItemGroup> <Compile Include="File1.py" /> <!-- List of files relative to .pyproj folder --> <Compile Include="test\file2.py" /></ItemGroup><ItemGroup> <Folder Include="test\" /> <!-- List of folders --></ItemGroup>
You can add more <ItemGroup>
elements if you want, and you can mix files and folder if you wish.
Script to generate the XML:
import osdef visit(folder): for fn in os.listdir(folder): filename = os.path.join(folder, fn) _, ext = os.path.splitext(fn) if os.isdir(filename): folders.append(filename) visit(filename) elif ext.lower() == '.py': files.append(filename)files = []folders = []visit('.')print '<ItemGroup>'for fn in files: print ' <Compile Include="' + fn + '"/>'print '</ItemGroup>'if folders: print '<ItemGroup>' for fn in folders: print ' <Folder Include="' + fn + '\\"/>' print '</ItemGroup>'
Show All files works. Show All files is in project menu.
Project->Show All Files
This worked for me in visual studio 2013, I don't know if this is applicable for other visual studio iterations.
After installing Python Tools for Visual Studio (PTVS), which I found here
Open visual studio, navigate to FILE->NEW->PROJECT (or hold Cntrl+shift+N)
On the new project dialog, Browse to your existing python project directory. Enter the name of your project in the project name field. uncheck create a directory for solution (if you do not wish to create a new project directory). And Select "From Existing Python code" option and click OK.
On the "create a new Project from Existing Python Code" Wizard, follow the prompts and make all necessary setting as needed or just click finish.