Giter VIP home page Giter VIP logo

cyotek.addprojects's Introduction

Cyotek Add Existing Projects Visual Studio Extension

Source and Support

Source | Issues

Background

My solutions used have lots of references to other projects as I would load common code as source code libraries. When creating a new solution (or retro-fitting an existing solution to use new libraries), I would end up using File | Add | Existing project a lot. As I was curious about how extensions in Visual Studio worked, I decided to write a very simple one to ease the grunt work of adding multiple common projects.

This simple extension, originally created for Visual Studio 2012 as I recall, is the result. I'm afraid it doesn't use WPF, so it's a touch ugly but it gets the job done.

Note that in the intervening years I finally converted almost 100 common library projects into proper NuGet packages and so I haven't actually needed this extension for some time. As some people find it useful I tend to create a new version for each new version of Visual Studio but that's about it at the moment - the extension isn't really actively developed.

Using the extension

Accessing the extension

To use the extension, open the Tools menu and choose Add Projects. This will open a lovely unthemed Windows Forms dialogue containing a list of projects that can be automatically added.

Projects are colour coded as follows

  • Black - no particular status
  • Grey - the project is already part of the active solution
  • Red - the source project cannot be found

Note that the first time you open this dialogue, the list will be empty - the MRU must be populated by yourself.

The main project window

Check each project you want to add to your solution, then click the OK button. It will then try and add each selected project to your solution, skipping any that are already present.

You can limit the projects displayed in the list by entering text into the Filter field. This filter text can be a regular expression and is matched on the entire filename, including the path.

Configuring settings

The setting dialogue

The settings dialog allows you to configure folder exclusions used by the Find Projects dialogue (for example you probably don't want to scan node_modules) and the project types used by both the Find Projects dialog and the manual file browser dialogue.

To display the settings dialog, click Settings from the main window.

Configuring folder exclusions

Enter the names of any folders you want to exclude from automatic scanning, one per line. These matches are a simple text match on a full path, so use directory separators to avoid partial matches - e.g. \bin\ to ignore all folders named bin, but not folders that contain bin.

Configuring project types

Enter a simple description and file mask for each type, one type per line. Separate the description and mask with the pipe (|) character. Multiple masks can be used, separate each with a semi-colon (;).

See the Filter property documentation for the FileDialog class for more information on this method of specifying filter options.

Adding a single project to the MRU

To add a single project to the list, click the Add File button then select the project you want to include.

Note: Currently changes won't be saved unless you click OK from this dialogue, or click the Settings button and then click OK from the Settings dialogue.

Adding multiple projects to the MRU

Scanning a folder for projects

To add multiple projects to the list, click the Add Folder button, then select a folder. The folder (and its sub folders) will then be scanned for any projects not already in the main MRU. Tick the projects you want to add, then click OK to update the main list.

Removing projects from the MRU

To remove projects from the MRU, select one or more projects, click the Remove button and then confirm the removal.

Note: Currently changes won't be saved unless you click OK from this dialogue, or click the Settings button and then click OK from the Settings dialogue.

Configuration Settings

The settings for the extension are saved into an XML file located at %AppData%\Cyotek\VisualStudioExtensions\AddProjects\config.xml.

<!--?xml version="1.0"?-->
<ExtensionSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <ExcludedFolders>
    <string>\bower_components\</string>
    <string>\node_modules\</string>
    <string>\bin\</string>
    <string>\obj\</string>
  </ExcludedFolders>
  <ProjectTypes>
    <string>C# Projects|*.csproj</string>
    <string>Visual Basic Projects|*.vbproj</string>
    <string>C++ Projects|*.vcproj;*.vcxproj</string>
    <string>F# Projects|*.fsproj</string>
    <string>NuGet Packager Projects|*.nuproj</string>
  </ProjectTypes>
  <Projects>
    <string>C:\Checkout\cyotek\source\Libraries\Cyotek.ApplicationServices\Cyotek.ApplicationServices.csproj</string>
    <string>C:\Checkout\cyotek\source\Libraries\Cyotek.ApplicationServices.Commands\Cyotek.ApplicationServices.Commands.csproj</string>
    <!-- SNIP -->
    <string>C:\Checkout\cyotek\source\Libraries\Cyotek.Windows.Runtime.Support\Cyotek.Windows.Runtime.Support.csproj</string>
    <string>C:\Checkout\cyotek\source\Libraries\Cyotek.Windows.Runtime.Testing\Cyotek.Windows.Runtime.Testing.csproj</string>
  </Projects>
</ExtensionSettings> 

The Projects element stores the MRU list of projects.

The ExcludedFolders element stores a list of folder names to ignore when automatically scanning a folder tree, for example node_modules.

The ProjectTypes element stores a set of filters that are used by file and folder dialogues.

Known Issues

These are the issues I currently know about - please let me know if you find anything else.

  • The extension is using Windows Forms instead of WPF, so it won't theme with VS
  • There's little error handling and it's not hooked up with the normal automatic error submission library I use. So if it crashes, it won't tell me automatically (so please raise an issue if it does!)
  • As I already mentioned, if you make changes to the core project list, it will only save it you select something to add to your solution.
  • It doesn't honour the current selection in the Project Explorer. For example, if you create and select a Solution Folder, using File | Add | Existing Project will add the project as a child. This extension won't, as by the time I'd finished writing it I could have filled several swear jars
  • The source code is awful, but it does work
  • It was written for an older version of Visual Studio. While it was updated slightly to support the new async model in 2019, I have no idea if it follows best practices for extensions
  • It can be a bit slow when adding lots of projects. I never did get around to seeing if it was possible to batch add projects to Visual Studio... it is still far quicker than doing it by hand

More information can be found on the Cyotek Blog.

Change Log

Please view the change log for this extension on the GitHub page for this project.

Installing the extension

When newer versions of Visual Studio were released, I discovered I couldn't compile the extension to support both the previous version(s) and the new... no doubt it is possible, but I wasn't willing to devote the time to it back then, and am even less so now.

Debugging the extension

Unlike with previous versions of Visual Studio, with VS2022 you can simply start debugging without having to make manual changes to the debug configuration - it will automatically open in the "Experimental" Visual Studio instance. You will need the Visual Studio 2022 SDK however. If this isn't already installed, Visual Studio will automatically prompt to install upon opening the solution.

License

The Add Existing Projects extension is licensed under the MIT License. See LICENSE.txt for the full text.

cyotek.addprojects's People

Contributors

cyotek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

cyotek.addprojects's Issues

Sign VS2017 VSIX package

The VS2017 VSIX currently isn't digitally signed. The tool I used to sign previous VSIX files doesn't seem to be working correctly as the final VSIX claims the signature is invalid.

Broken support for VS2012

AlexO comments

Does not work on VS2012

<entry>
<record>457</record>
<time>2016/05/19 21:30:01.242</time>
<type>Error</type>
<source>VisualStudio</source>
<description>End package load [AddProjectsPackage]</description>
<guid>{AF385D18-DD14-4C1B-A4AD-3E69C525312F}</guid>
<hr>80004005 - E_FAIL</hr>
<errorinfo>Could not load file or assembly 'Microsoft.VisualStudio.Shell.11.0, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.</errorinfo>
</entry>

Need to either figure out if extensions compiled with VS2015 can be compatible with earlier versions, or remove the support from the manifest.

Batch operations

Comment posted by Arthur Medinsky to the gallery page

This extension is brilliantly works. (Just use Tools > Add projects in VS menu instead of usual way). Thank you for this.

However, there's an odd thing that kills its function and you should fix it.

When working in Visual Studio solution loaded from network drive (CLR treats it as "untrusted"), you will see message box for confirming adding project from "untrusted source".

"You should only open projects from a turstworthy sources...Would you like to open this project?"

Normally this message box appears when loading solution, and there's a checkbox to skip this confirmation for all other projects except first.

When this extension add projects, this box appears for each project, and that checkbox doesn't seem to work. I think this is major issue and must be fixed as i am bored clicking "OK" for 20+ times in my case.

Please fix this.

Haven't see this myself as I don't run projects over UNC shares but something to try and fix if it's possible.

Update Framework versions in manifest

golpask pointed out

It'll be interesting to allow recent version of .net framework (>4.5) in the installation process of the extension. I've done this using: anaisbetts/SaveAllTheTime#39
Update your manifest to add [4.5,) in .net framework version.

Looked at the referenced manifest, need to add a variation of this line:

 <SupportedFrameworkRuntimeEdition MinVersion="4.0" MaxVersion="4.6" />

However, there are other differences - my manifest uses an InstallationTarget element, theirs uses SupportedProducts. Need to check what the differences are and make sure my manifest is as broad as possible.

Feature: Add a cancel button

While importing several hundred projects I changed my mind part way through the process and it would have been nice to be able to stop the rest of the import (possibly with the option to undo the the addition of the projects added so far).

Sent from my Motorola Nexus 6 using FastHub

[Feature] Add multi-projects functions

It would be great to have multi-projects functions like:

  • Edit multiple .csproj of loaded/unloaded projects
  • Link file to multiple projects (with relative or absolute paths)

Search should delegate to file system instead of enumerating every single file

L106 of FindProjectsDialog:

foreach (string fileName in Directory.GetFiles(path, "*.*", SearchOption.AllDirectories))
{
    if (_searchPattern.IsMatch(fileName) &&
        !_existingFiles.Any(f => string.Equals(f, fileName, StringComparison.InvariantCultureIgnoreCase)))
    {
        projectsListView.AddFile(fileName, true);
    }
}

This should delegate to the file system instead of enumerating every file, which is incredibly expensive and makes this extension unusable on any project with a node_modules.

Instead, consider making the search pattern compatible with the Directory.GetFiles API and handle the returned files. I'll PR this if I get time tonight :).

Support VS 2017

I love this extension, saves me a bunch of time on each new project.
Please add support for Visual Studio 2017. Thanks!

Changing the filter text resets selection

When you're batch adding projects, you want to be able to select project across multiple filters, so whenever we check something we should add it to a checked list rather than relying on the checked property (potentially even changing the checkbox to a button to avoid confusion) and have a separate list view with the added projects (allowing to remove them from there).
This way they would survive changes in filtering and enable even more productivity.

PS: I might do this myself and PR, just created the issue so that it's reported.

Default project type should be all the project types

Just like when you add an existing project to visual studio. The file type filter on the File Dialog should be all the project types. I believe the filter should also include the others, but I have found the current functionality inconvenient when working with a solution with the dreaded vb.net project.

Add Visual Studio 2017 Support

Not a real problem, because the extension works without any issues in Visual Studio 2017. However, the installer does notify the user that it could cause visual studio to become unstable.

Feature: Enable lightweight solution

The extension could offer the option to enable lightweight solution if supported (it's a VS2017 feature). This could be as an option on the dialog and/or as a prompt if the user selects a lot of projects. A brief description of lightweight solution load would probably be useful too.

Sent from my Motorola Nexus 6 using FastHub

Feature: Add progress bar

I used the extension to add several hundred projects which took a little while. It would be nice to see a indication of progress.

Sent from my Motorola Nexus 6 using FastHub

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.