ChatGPT解决这个技术问题 Extra ChatGPT

Empty Visual Studio Project?

Is there a way to have an empty Project in Visual Studio 2008 or 2010? I do not mean an empty solution, I mean an empty project in a solution. Basically I have a solution with multiple projects, and I want to add a project to track some static files that are part of the solution but not of any specific project. Adding them as solution files doesn't work because solution folders are not mapped to file system folders and I want to manage hierarchy from Visual Studio.

At the moment I create an empty Visual C# project which works, but I just wonder if there is a "more empty" project.

What type of files do you want to add ? and do you want to do with them ?
In my case it's the Sharepoint 14-Hive. Basically I need to mirror the file system (including subfolders) to track any files I add to it. Sometimes, these files are simple graphics or CSS Files and as such not part of any Development Project, but I still like to track them. The main need is to move and rename them and have those changes mirrored in the file system. Also, source control is easier that way for me.
So, what's the actual problem? Why is empty not empty enough?
There is no "Empty Project" in Visual Studio, only "Empty Solution", and solution folders don't work as they do not affect the file system. An "Empty C# Project" still has Compiler Options and the "References" virtual folder, and I was hoping to get rid of them.

J
Jeson Martajaya

I was misled by the C++ "Empty Project" or "Makefile Project". I cant create new folder there.

Here are three steps to add an empty C# project:

1) Create the project. (Add > New Project > Visual C# > Windows > Empty Project)

2) Exclude it from build. (Build > Configuration Manager, uncheck Build on both Debug and Release configuration)

3) Replace its csproj content with the following 3 liners:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>

There you go. You can create a folder in this project, yet it does not build.


This is the best answer, and the sort of thing that MS ought to include by default. Solution Folder are a PITA to manage.
Visual C# → Windows → Classic Desktop → Empty Project for VS2015
@JohnGrabanski Program does not contain a static 'Main' method suitable for an entry point
I don't have Visual C# > Windows > Empty Project in VS 2015
M
Michael Burr

The Visual C++ project types has an "Empty Project" in the "General" category.

It comes up with several empty folders ("Header Files", "Resource Files", "Source Files") that are just 'filters' (they aren't on the file system). You can just remove them.

It also has all the properties of a C++ project available, so don't put C/C++ files in there unless you want them built (or you exclude them from the build).

Other than that, it's pretty empty.

Probably even closer to an "empty project" is a "Makefile Project" which is also located in the "General" category of the Visual C++ project templates. It also creates the 3 filter folders, along with a readme.txt file that you can delete. It has the advantage that unless you specifically give it commands to run during the build, it won't do a damn thing.


The empty C++ project won't do a 'damn' thing either when you go to Project Properties and select Utility under Configuration Type under the General tab.
Shame you can't add folders to the project. I ended up just using an empty C# project because of this
Utility projects are very useful to include "headers-only" libraries, so you can reference them from your projects easily. It would be nice if VS allowed you to create this in one step. Similarly I would like to be able to create an empty DLL project (which most of mine are) in one step ratehr than have to modify from .exe to .dll every time.
C++ Makefile project and empty project don't support folders :(
I think they do support folder. See my answer below, because I could not include the image in a comment.
s
spinxz

For Visual Studio 2015 up this can now be done with so-called Shared Projects. This is simply an empty project type that holds source files for use within another project, see here.


This is good, as long as there is no code in there. If any project needs to reference this project, then it has to be in sync dependency-wise. So for just serving as a placeholder for static files, this would work well.
This is working well for me -- the one change I made is to have the project automatically add all files under its directory while maintaining directory structures. Auto adding is easy, just add the following within an item group: <Content Include="$(MSBuildThisFileDirectory)**\*.*" /> I also threw this into a gist which can be found here
N
NightShovel

I found an "Empty Project" under the "Windows" category in both C# and Visual Basic, in Visual Studio 2012. I'm unsure if these are present with Visual Studio 2008 or 2010.

It seems to only create an App.Config file, which can easily be deleted.


It still tries to compile the contents, which isn't always desirable
N
Niklas Peter

I think the C++ empty project does support folders. At least in VS 2013 you just have to click on "Show all files" in the Solution Explorer. Then it will not show these virtual folders (filters) anymore, but real folders in the file system and then you can also create new folders, ...

https://i.stack.imgur.com/B8mGc.jpg


P
Paul Creasey

Sounds to me like you want a solution folder!


Solution Folders to not mirror Directory Hierarchy. If I create a solution folder inside another solution folder and move a file into it, the file does not actually get moved into that folder in the filesystem.
Ah fair, i thought it was likely to simple to to be true, but you never know!
Another downside to this is that I have noticed that a TFS build does not put the solution items into the drop folder.
H
H3sDW11e

Microsoft Visual Studio 2019 Community Microsoft Visual Studio 2017 Community Microsoft Visual Studio 2015 Community

https://i.stack.imgur.com/DqLaF.jpg

now to work with this Empty Project, References must to be Add to the Project; in Solution Explorer, right-click References then Add Reference... select these references: PresentationCore, PresentationFramework, System.Windows, WindowBase; then click OK;

https://i.stack.imgur.com/Vont9.jpg

starting coding and creating your Dynamic Generated WPF Application; follow these steps if more References are needed depending on the code used;