How to remove metadata from a Visual Studio project? - visual-studio

I have personal Visual Studio projects that I would like to expose to the internet. I'm using BatchPurifier to remove metadata from various files but I doubt it gets whatever Visual Studio does.

You only need to "expose" the solution, project and source code files. These are all plain text files that do not contain metadata and can be reviewed with a simple text editor. They do not contain secrets unless you put them in yourself.
If you have resources as well then it is entirely up to whatever program or device created the file, Visual Studio isn't involved.
Poking around github or codeplex is a good way to find out how other programmers publish their projects.

Open the solution and project files in a text editing program such as notepad and remove any metadata you find unnecessary. I doubt you will find a tool to remove exactly what you want, you'll have to do it manually.

Related

Visual Studio - How to find which solution a source file is part of?

I'm working ona project containing thousands of solutions (.sln) and tens of thousands of .cs/.cpp/etc files.
How can i find which solution(s) a source file is a part of?
Source files aren't part of a solution. They are part of a project, which in turn is part of a solution. The source file itself has no notion of being part of the project though. The project has a reference to the file but not the other way around. One source file can be part of multiple projects, which might be part of different solutions.
What you could do is parse the SLN and VBPROJ/CSPROJ/whatever files to see which ones refer to a particular source file. Those files are just text and contain various information about the solution or project, including what projects are part of a solution and what files are part of a project. You could recursively parse the files in folder to build up an entire tree representing the files in the projects in the solutions.
Note that most files are going to be referred to by relative paths in the project file.
Start with Visual Commander and then you can programmatically access your solution "DOM-style" using Visual Studio's Automation and Extensibility for Visual Studio API. Write a VS command in a .NET language that traverses a solution into its projects and then into the project items, dumping all files found (project items) into a log file, database, web service, what have you.
See e.g., this article HOWTO: Navigate the files of a solution from a Visual Studio .NET macro or add-in on how to navigate Visual Studio's DTE.
I know SO frowns on answers containing just links and not true help, but the documentation for EnvDTE in its various flavors is extensive and any code sample to demonstrate how to use it would be quite large. So I'm just giving you this strong hint: Look at the Visual Studio extensibility model, and hook into it easily via Visual Commander which does all the hard work of wrapping your code in a Visual Studio extension. From there you can use any reasonable technique (MSBuild, PowerShell, batch files) to load each solution into VS and run your new command.
This actually answers the question: For all source files used by any of my thousands of solutions, which solutions use them. But I see that you (#Sabz), below in a comment, give a reasonable way to answer the question for one source file at a time, which is more precisely what you asked.
N.B.: I have not (yet) used Visual Commander so I'm just assuming it works as advertised.

Create Visual Studio Project using files on Server

How do I create a Visual Studio Project for Development on my Local PC that links to Existing files and folders on a Server?
My employer has a large website. Most of that girth (close to 100 GB) is contributed to Portable and Image document (i.e. PDF and JPEG) files, but there are also numerous web files (.html, .aspx, .php, etc).
We have the following folders:
a WORKING folder that contains everything that is "Live" on our web server.
a BETA folder that contains newest technologies that are being tested and tried.
a DEVELOPMENT folder that contains numerous copies of projects that are being worked on by the different developers.
Developers are allowed to use whatever tools they prefer, so we have people who develop using Notepad++, Dreamweaver, Komodo, Zend Studio, and (now) Visual Studio.
It is NOT OK for me to create Visual Studio Projects for myself on the network servers. Other developers using other tools are not creating solution files or \bin and \obj folders on the servers, and I certainly should not be either.
So, to work on a file in Visual Studio, I use Windows Explorer to browse to the location, then I open it in the IDE.
However, this causes me to lose a lot of the power of Visual Studio - particularly if other classes used in this file, because I would have no access to the Intellisense for that class and I cannot simply Right-Click and go to definition.
Also, since each development environment is so large, I can not copy them to my laptop with its high tech 125 GB Solid State Drive (should be interesting to read that in a couple of years).
What I would like to do is create the Visual Studio Projects on my local drive, and then have them reference the files and folders on our network.
I've looked and found these similar questions, but my goal is slightly different:
Working efficiently on remote projects in Visual Studio
How do I add an existing directory tree to a project in Visual Studio?
How to "Add Existing Item" an entire directory structure in Visual Studio?
These are all great topics, but none of them show a way to create a local project that uses remote files.
It would seem that developers in large company teams would have already developed a way to do this, and that I just do not know what it is called.
I have found a way to do this!
For a long time, I was working with 2 sets of folders. One for our repository and one for Visual Studio.
I'd make changes in Visual Studio, then copy those working files over to the repository folder.
That was time consuming! Very.
Here is how I found to fix it: Open the Visual Studio Project file (*.csproj, *.vbproj, or *.phpproj) in NOTEPAD with Visual Studio closed.
Locate the <ItemGroup> tab, and change every path to be from the one shown to one that uses a relative path to get to the actual files.
Notepad's Replace... CTRL+H will save you hours here!
It makes a funky looking project environment, but it works!
If this helps anyone else or if it were even something you didn't know you could do to manipulate Visual Studio, kindly vote it up.

Creating Visual Studio Solution Files Automatically

I have several Visual Studio .vcproj files which are auto generated, I would to automate the process of creation a solution file which includes all those .vcproj files.
Are there any command line tools which I can use the automate this as part of our build process?
P.S. It is possible to write some code to handle the necessary processing to handle this. However I am hoping for a MS provided commmand line tool which can handle various version of Visual Studio for now and the near future.
Visual Studio does have tools for generating GUIDs. If you reverse engineer .sln and .vcproj files using a text editor, you'll know enough to put together a script that can write a solution file.
From this link, you get some clues about the project type GUID:
The first GUID listed for each project is the type of project. For instance, a VB.NET project (vbproj) has this GUID: {F184B08F-C81C-45f6-A57F-5ABD9991F28F}. You can find all the GUIDs that Visual Studio uses in the registry under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\7.1\Projects\
The second GUID identifies the individual project. It corresponds to the GUID value found in the project listed in the solution file.
I'm about to give this a shot. Like someone said in the comments, this is a bit of a niche problem, so you may need to roll your own.

VS2010 MV3 - How can I share files between solutions?

I am the only developer for an application. All the files for this application are stored on the same computer and I am using Visual Studio 2010 Ultimate.
The application has three solutions and these share common items such as some stylesheets, some javascript and shared views.
It's starting to become difficult when I change one file as I have to copy this to the other projects in the other solutions.
Is there a simple way that I could share files. Something that would help me be more productive. Possibly even some single user source code or a way of linking files between solutions.
Hope I can find someone to help me make my life easier.
Robert W
Even if you work on your own I would suggest some kind of Source Control System. Team Server is now free with Visual Studio or you can use open source tools. Like this you can link to source files in other projects and you can reuse your files.
Use Source Control! SVN is free so is TFS with Ultimate.
If its web based files (javscript, pictures, css, etc) use a virtual directory to point to the common code directories.
if its compiled code (C#,VB, etc) you can link the files. When adding an existing file in the dialog it will have a open button, with an arrow down. click the arrow down and "add as link" will be available. It will then use relative referencing to the other file. I use this technique for a SolutionAssemblyInfo.cs file.
I would recommend placing the common files in the same directory as the solution file or no more than 1 folder deep.

Is there a tool to automatically convert a make file to sln/vcproj?

Google reveals many tools for taking Visual Studio format sln/vcproj files, and producing a make file from them. But I can't find one that solves the opposite problem - I have a make file that references hundreds of .c and .h files and (for convenience, for debugging, for writing code in the VS IDE) would like to open it as a Visual Studio project.
Where can I find a tool to take an arbitrary make file as input, and produce Visual Studio project/solution files as output?
Makefile Project Wizard
You might be able to find a converter for a well-constrained set of makefiles, but a converter for any arbitrary makefile would be tricky. They are mini-programs, after all, that would have to be evaluated. And not all makefile concepts map directly to Visual Studio projects.
If you only have one project to worry about, I'd just manually put together a project in Visual Studio (tip: you can select more than one file in the "Add existing file..." dialog). If you do this regularly, perhaps look into a tool like Premake or CMake to help automate the generation of the projects (and if necessary, a new Makefile) for you.

Resources