English 中文(简体)
How can I automatically add existing items to a Visual Studio project?
原标题:

I have a tool which dynamically generates .xaml and .xaml.cs files and puts them in the appropriate Visual Studio directory.

To add them to the project, I have to then:

  • right-click on that directory
  • choose "add existing item"
  • navigate to the matching directory on the hard drive
  • select the two files that were created
  • click ok

Is there a way for me to tell the project to "include all existing items under the project folder on the hard drive"?

最佳回答

I do not have any automation for this. Still I follow following for the same requirement. This will avoid few clicking.

  • In solution Explorer highlight/Select "Show all files" button
  • Press control key (to multi select) and select files with mouse click to be included in solution.
  • Right click on any one of highlighted file, and select "Include in project"
问题回答

You can do this programatically in your .proj file depending on your needs just like this answer

You just have to make sure you use the correct tag for the files.

Compile, Content, None, etc..

<ItemGroup>
  <Content Include="Images***.*" />
  <Compile Include="Subdirectory***.cs" />
</ItemGroup>

How to add files automatically into a Visual Studio project

Here’s a tip to automatically add all files that are in a particular folder into a Visual Studio (C++) project so that you won’t need to add files newly added in that folder into the project.

In the file .vcxproj, remove all CLCompile elements inside tag and add

<ClCompile Include="[Path to your source folder]*.cpp" />

Do the same for header files. Now, your cpp and h files will be included automatically.

I don t think there is a way to do this natively in Visual Studio. Adding the files to the project modifies the project file.

This sounds like a good case for a simple addin. You can use the Visual Studio automation services to find the files you want added and add them all at once. You d have complete control over the behavior of the addin, so you could reduce the process to a single click if practical.





相关问题
building .net applications without Visual Studio

I m interested to hear about people working with building .net applications using MSBuild, NAnt or similar tools. What are you using, why are you using it instead of the VS IDE? I like to use ...

Tips for debugging a made-for-linux application on windows?

I m trying to find the source of a bug I have found in an open-source application. I have managed to get a build up and running on my Windows machine, but I m having trouble finding the spot in the ...

Visual Studio 2010 Beta 2: Can I print in color?

I have to turn in a hard copy of some code with an assignment. Is there any way in Visual Studio 2010 to print C# source code with syntax highlighting? PS: The assignment is solving a math problem, ...

Set Select command in code

On button Click I want to Set the Select command of a Gridview. I do this and then databind the grid but it doesn t work. What am i doing wrong? protected void bttnView_Click(object sender, ...

WPF design-time context menu

I am trying to create a custom wpf control, I m wondering how I can add some design-time features. I ve googled and can t seem to get to my goal. So here s my simple question, how can I add an entry ...

热门标签