How can I automatically add existing items to a Vi

2019-01-27 13:57发布

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"?

3条回答
对你真心纯属浪费
2楼-- · 2019-01-27 13:59

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.

查看更多
够拽才男人
3楼-- · 2019-01-27 14:04

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"
查看更多
混吃等死
4楼-- · 2019-01-27 14:23

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>
查看更多
登录 后发表回答