madskristensen / addanyfile Goto Github PK
View Code? Open in Web Editor NEWA Visual Studio extension
License: Apache License 2.0
A Visual Studio extension
License: Apache License 2.0
When opening a solution in Visual Studio 2013 I am presented with the dreaded The 'AddAnyFilePackage' package did not load correctly.
error message.
When opening a solution in Visual Studio 2013 I am presented with the dreaded The 'AddAnyFilePackage' package did not load correctly.
error message.
The ActivityLog.xml file contains the following entries:
<entry>
<record>803</record>
<time>2016/06/13 19:45:59.336</time>
<type>Error</type>
<source>VisualStudio</source>
<description>CreateInstance failed for package [AddAnyFilePackage]</description>
<guid>{27DD9DEA-6DD2-403E-929D-3FF20D896C5E}</guid>
<hr>80070002</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>
<entry>
<record>804</record>
<time>2016/06/13 19:45:59.336</time>
<type>Error</type>
<source>VisualStudio</source>
<description>End package load [AddAnyFilePackage]</description>
<guid>{27DD9DEA-6DD2-403E-929D-3FF20D896C5E}</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>
Solution opens and package loads properly
Add support for adding multiple files from the dialog if the user provides a comma separated list of file names. This would be especially helpful for SPA components that leverage.html templates with .js view models.
Example 1:
IEmployee.cs, Employee.cs
Gold Plated version:
SPA / MVVM style components often follow the pattern of (component-name<.html|.js>), in this situation users would likely prefer a shorthand syntax for specifying just the extensions.
Example 2:
widget1[.js][.html] // creates widget.js and widget.html
widget1[js][html] // works the same - leading period is optional
Example 3
webform1[.aspx][.aspx.cs] // creates webform1.aspx and webform1.aspx.cs
webform1[aspx][aspx.cs] // works the same - leading period is optional
webform1.aspx[cs] // only creates webform1.apsx.cs
Example 4
widget1[js][html], widget2[js][html], site.css // creates widget1.js, widget1.html, widget2.js, widget2.html, and site.css
Hello,
First of all thanks for the plugin, it is super helpful.
I would like that you could specify what encoding format there should be used when saving a file.
For example i have used the plugin to create .html files. It gives some problems because I have to use UTF-8 encoding because I have some Nordic characters in the html file like: æøå.
At the moment the files created with the AddAnyFile plugin always save the files with ANSI encoding.
Thanks for the Awesome extension.
Now, If I was in folder A, and hit shift+F2, I can add files & folder to current folder.
But I think will be better if you ignore current place and allow the user to create files & folder from root.
The extension cannot create a new file, when inside a solution with mutliple projects..
visual studio supports creating multiple projects within one solution and can distinguish easily between them.
does not support multi project setup.
create the file regardless
It would be nice to be able to create generic files directly.
The convention we use is MyClass{T}.cs
and the file contains class
public class MyClass<T>
{
}
The class name created now is MyClass{T}
which is an incorrect class name. I also understand that other projects have different conventions so there could be a template file.
When I try to create a new file and press Shift-F2, I get a dialog to input the name of the file.
I input a standard filename with extension ".cs", then an error message pops up:
"Could not create test.cs"
"Falscher Parameter. (Ausnahme von HRESULT: 0x80070057 (E_INVALIDARG))"
Translatet this means:
"Wrong parameter. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))"
After clicking OK in the error message dialog box you can validate, that the file is created in contrast to the message of the error dialog.
Error message is displayed for each creation of a file
No error message is displayed.
When adding new .sql files under (ex) dbo\Tables, the files get created in the right place on the disk but end up at the root of the project as a 'miscellaneous file'. This causes issues where files need to be manually deleted (as the project doesn't allow you to move them to fix it). I get an error dialog when trying to move the file back into the right place. This doesn't apply to just dbo\Tables ... Your extension seems to have compatibility issues with SSDT entirely.
The file ends up at the root of the project and is treated as a 'miscellaneous file'. On the disk, it is saved in the right place.
It should end up being treated the same as any other tables created through the Add New File dialog.
16.06.2017 09:34:31: System.Runtime.InteropServices.COMException (0x80004005): Beim Aufruf einer COM-Komponente wurde ein HRESULT E_FAIL-Fehler zurückgegeben.
bei EnvDTE80.DTE2.ExecuteCommand(String CommandName, String CommandArgs)
bei MadsKristensen.AddAnyFile.AddAnyFilePackage.d__2.MoveNext() in C:\projects\addanyfile\src\AddAnyFilePackage.cs:Zeile 114.
Install in ViS via "Extension And Updates" - "Online" - "Visual Studio Marketplace"
Open a .NET project, add a "test.html" file wirh "New Empty File"
The file is correctly created but the message under ###Description appears in output window of VS
No error message
Hi,
At build 2016 Microsoft released Visual Studio 15 Preview.
There are some extensions that work there, but some that are not even searchable in "Extensions and Updates". Yours is one of those that are not searchable and not installable.
Your extension is not searchable in new Visual Studio 15 Preview
Your extension should or could be also in VS15Preview :)
Btw, I created recently one analyzer and made it to be an extension and it works there fine:
https://github.com/jakubsuchybio/DebuggingUsingsInsertor-Analyzer
If you needed something to compare yours setup of extension with.
Regards.
Selecting the New Empty File... option from the context menu does nothing.
If I use the keyboard shortcut the file is created in the correct folder, but it is not added to the solution or opened in the editor.
Is there somewhere I can get a log file from?
I very much like the way the new folder
UX works. Instead of a modal, it creates a temporary to be named file on filesystem (empty).
If it's possible, may I suggest that design change?
If you need extra options for some files (like a controller with views, etc) to actually be on a modal, I can suggest to bring that up after the file name is chosen, and only if necessary.
If I add a typescript file (*.ts) it creates the file, but the file won't be added to project.
Wouldn't it be nice to enable quick creation of a C#/VB.NET test classes by using the *Test.cs convention? I would be happy to contribute!
Noticed this in a new ASP.Net vNext project. When I right click on a folder and add a new file, the file gets added to both the selected folder and the solution root.
Might be an issue with VS2017-P3, but wanted to be sure it wasn't something odd. Since it is a .NET Core project, creating the file/folder should be all it does (as no project file needs to be touched, in fact sometimes I get a csproj entry (most times I don't) which is problematic.
Slow. (I have a quad core, 32GB fast RAM, 3TB SSD machine, nothing should be this slow.
Should be much faster.
Somehow my instance of Visual Studio 2012 was able to automatically update to the current version on the Marketplace, even though it does not support 2012. Now the extension does not work anymore. Is there somewhere that I can download the latest version that supports 2012?
Seems like a name can only have one "." for the file extension such as foo.js. But foo.bar.js will not work.
After cloning and installing extensibility SDK, I can't actually build. A bunch of references aren't resolving, and I'm unsure where they should be coming from (I would have thought the SDK, but apparently not):
I noticed that at least some of this stuff is on NuGet, but they were not added as NuGet dependencies.
Unable to build due to missing references.
Should be able to build.
Hi Mads,
whenever I create new file using your extension (I use it especially for README.md and such) I have to go to File / Advanced Save Options... to change the encoding of the file to UTF-8 with signature as the file is created using default Windows encoding (in opposite to files created using VS or R# where there is UTF from the very beginning).
I often use the extension to add test files which needs to be copied to output dir. It's tedious to go to properties and switching "Copy to output directory" to "Copy if newer" for each new file. I though it would be nice to have a option right in the AddAnyFile dialog box.
What do you think?
PS: Oh, and thank you for the extension, it's really cool.
I tried using this pluing in Node.js project in VS2015, but it throws "Folder already exists" error when I tried to create a new JavaScript file.
What I do is:
When right-clicking on the project and selecting Add->New empty file, I get a "Microsoft Visual Studio has stopped working"
Same goes when selecting the project and pressing ctrl-F2.
When doing the same on the wwwroot folder inside the project, It seems to be working fine.
Using commas in file names creates multiple files.
Class{T1,T2,T3}.cs is a valid file name and a pattern often used.
Creates files:
Creates file Class{T1,T2,T3}.cs
I keep enabling this extension and it keeps getting disabled by something else and I have no idea what or why.
No specific steps - this presumably is a problem for you or it is not.
The extension keeps getting disabled.
When enabled the extension should stay enabled until I manually disable it.
I've always thought it has been visual studio's fault but adding a new file normally doesn't produce this problem. This is what an added c# file looks like:
You can see that the EOL chars are mixed.
I'm using this extension to visualize EOL characters.
To reproduce simply try adding a c# file.
I usually directly close and open the file, visual studio will then tell me that the file has mixed EOL endings and offers help.
Just a suggestion. I'm used to VS "new class" window where .cs extension is added automatically so it's just a muscle memory to omit it with AddAnyFile. I end up creating new files with no extension, deleting them and adding again with .cs almost every time. Wouldn't be nice if we look into the directory and if all the files have the same extension just use it when none specified.
Not working anymore in C# Shared Projects (used to work just fine until last update)
The file is created on disk, but not in the project.
An exception is thrown:
22-Aug-18 13:35:03: System.NotSupportedException: No item can be placed here.
at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.ProjectNode.<AddItemWithSpecificAsync>d__613.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.Automation.OAProjectItems.<AddItemAsync>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.Automation.OAProjectItems.<>c__DisplayClass4_0.<<AddFromFile>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Threading.JoinableTask.CompleteOnCurrentThread()
at Microsoft.VisualStudio.Threading.JoinableTask`1.CompleteOnCurrentThread()
at Microsoft.VisualStudio.Threading.JoinableTaskFactory.Run[T](Func`1 asyncMethod, JoinableTaskCreationOptions creationOptions)
at Microsoft.VisualStudio.Threading.JoinableTaskFactory.Run[T](Func`1 asyncMethod)
at Microsoft.VisualStudio.ProjectSystem.ProjectMultiThreadedService.ExecuteSynchronously[T](Func`1 asyncAction)
at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.Automation.OAProjectItems.AddFromFile(String fileName)
at MadsKristensen.AddAnyFile.ProjectHelpers.AddFileToProject(Project project, FileInfo file, String itemType) in C:\projects\addanyfile\src\Helpers\ProjectHelpers.cs:line 108
at MadsKristensen.AddAnyFile.AddAnyFilePackage.<MenuItemCallback>d__2.MoveNext() in C:\projects\addanyfile\src\AddAnyFilePackage.cs:line 94
22-Aug-18 15:16:41: System.NotSupportedException: No item can be placed here.
at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.ProjectNode.<AddItemWithSpecificAsync>d__613.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.Automation.OAProjectItems.<AddItemAsync>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.Automation.OAProjectItems.<>c__DisplayClass4_0.<<AddFromFile>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Threading.JoinableTask.CompleteOnCurrentThread()
at Microsoft.VisualStudio.Threading.JoinableTask`1.CompleteOnCurrentThread()
at Microsoft.VisualStudio.Threading.JoinableTaskFactory.Run[T](Func`1 asyncMethod, JoinableTaskCreationOptions creationOptions)
at Microsoft.VisualStudio.Threading.JoinableTaskFactory.Run[T](Func`1 asyncMethod)
at Microsoft.VisualStudio.ProjectSystem.ProjectMultiThreadedService.ExecuteSynchronously[T](Func`1 asyncAction)
at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.Automation.OAProjectItems.AddFromFile(String fileName)
at MadsKristensen.AddAnyFile.ProjectHelpers.AddFileToProject(Project project, FileInfo file, String itemType) in C:\projects\addanyfile\src\Helpers\ProjectHelpers.cs:line 108
at MadsKristensen.AddAnyFile.AddAnyFilePackage.<MenuItemCallback>d__2.MoveNext() in C:\projects\addanyfile\src\AddAnyFilePackage.cs:line 94
Include the created file on the C# Shared Project.
Files are beeing created incorrectly when currently edited file and selection in Solution Explorer are in different projects.
Library
Application
Folder
to Library
projectFile1.cs
to Library
projectFile structure should be like
Solution
- Library
- Folder
- File1.cs
- Application
- Program.cs
File1.cs
in editorProgram.cs
in Solution ExplorerFile1.cs
editorFile2.cs
and press [enter]Folder/
.Library/Folder/File2.cs
.Library
projects.Application
project as a link.Application..Library.Folder
Library/Folder/File2.cs
and is added to Library
project. Focus is set on File1.cs
so I'd expect to execute actions in this context.Library.Folder
Great extension but is it possible to create a file with UTF8 by default?
JSON file encoding should be UTF-8-BOM (for ASP.NET Core Projects).
When adding a JSON file using this extension, I get an ANSI encoded file. Using this file with special characters (äöü) as a configuration file, those characters are not read correctly then. Using Notepad++ to change the encoding of the JSON file to UTF-8-BOM (and manually converting the special characters) fixes the problem.
When adding a JSON file the VS-way (add->new item->json), the encoding of the file is set correctly and there are no problems when reading the configuration.
Add the JSON file with the UTF-8-BOM encoding.
If extension is used the added file does not picked up by source control in VS2015. In other words these files will never be in repo IF not re-added manually.
Could be VS2015 issue and not the extension's, I'm not sure.
Cannot add file to solution folder. Visual studio crashes when user presses [Shift]+[F2] on file in solution folder.
Both step 4 and 7 should open new file dialog and add file to solution folder.
Customizations to Visual Studio's template files are ignored by Add New File because it has its own templates.
VS item templates are ignored.
Either VS item templates should be used, or Add New File should provide a means of customizing its templates.
Fork the project, modify the built-in templates, and run a custom build of the extension. Not ideal for obvious reasons.
Visual F# Power Tools extension allows me to add folders to F# projects, but when i try to add a new file to a folder using this extension, the file is in the folder on the file system but not in the folder in the project system.
Selecting subdirectory A in Solution Explorer, and creating a new file with "../" in its path in order to create it one level up, actually creates a new pseudo-subdirectory node named ".." under subdir A. The file does appear under this node, and appears at the correct level in the filesystem (i.e. the parent of subdir A), but there are two problems:
The behaviour as described also holds when more than one ../ is used in order to traverse more than one parent directory.
New ".." node(s) created in Solution Explorer, one for each used in the new file's path.
The Solution Explorer node contains only the newly created file(s), but deleting the node deletes the entire corresponding ancestor directory, with more deeply nested ".." nodes representing successively higher ancestors.
The new file should appear under the existing node corresponding to the intended ancestor directory, possibly with the restriction that "../" is ignored if it would traverse beyond the project directory.
Can you add/show the complete path in the new file dialogue
and when possible make it editable
Show complete path, like C:\Git\MySolutions\MyProject\Enumerations\
The default file encoding of UTF-8 is not handled well by a non-Microsoft compiler - it sees the first three characters as an illegal token
It seems the current UTF-8 encoding is the default, and can't be changed.
Allow user to select the default encoding. (In this case, I would select ANSI encoding.)
When i use this Extension Visual Studio crashes when i first add a new file and a new Folder with the same Name as the file.
Visual Studio crashes
Display an error message box. Visual Studio does the same when i try to do it with --> Add --> New Folder
This extension is beautiful and should be added into vs 2015 RTM.
I like the templates feature and for .cs files it would be great if it created something more like
using System;
namespace {{DefaultNamespace}}.{{Path}} {
public class {{FileName}} {
$
}
}
I would also make the templating not only on the extension. For example, if the file name starts with a capital I and the second letter is uppercase I will make it an interface
namespace {{DefaultNamespace}}.{{Path}} {
public interface {{FileName}} {
$
}
}
if it's suffix is Controller, like SomeController.cs I would love to see the controller template, and more patterns.
Also some known files like gulp-config or bower.json, config.json all can have a different template not only based on file extension.
Lastly, when/how can one start helping on the templates ? I'm really exciting to see this as the default file new ;)
Consider a project with a default namespace of Foo
.
Add a new file in a folder Bar
.
The added file has the namespace Foo
.
The namespace should be Foo.Bar
.
Uses Spaces when my IDE is set to use Tabs. A very minor issue but I thought worth reporting.
Using spaces for templates always.
Respect what the IDE is set to for that specific file type.
Thanks for the great extension Mads, I use it every day :)
The extension is not following the formatting settings the user has set in the Visual Studio options dialog.
When I create a new C# file all the opening braces are placed on a new line. Our team places our open braces on the same line as the class/namespace declarations. Our Visual Studio settings are set up to match this. After installing AddAnyFile I noticed that it doesn't respect these Visual Studio settings.
AddAnyFile should be adhere to the formatting settings the user has selected in the Visual Studio options dialog. When I create a new C# file my opening brace should be on the same line as my class/namespace declaration.
Your extension stores newly created files using UTF8 encoding WITHOUT "UTF8 identifier" (see file AddAnyFilePackage.cs, method WriteToDisk, line 159 now). But even if the file uses one of your templates Visual Studio can't correctly recognize the encoding of the file. It thinks it is the default encoding of the OS. When I add some text to the file which has different codes in UTF8 and Default encodings (e.g. "Привет") Visual Studio still saves this file using Default encoding.
It is very annoying then I write .html pages or templates. Browser expects them in UTF8 (I state it in 'meta' tag) but actually encoding is different. And I have to manually re-save all my files in UTF8 encoding.
At the same time when I create a new file using standard Visual Studio means (Solution Explorer ->
context menu -> Add -> New Item) it creates file using UTF8 encoding WITH "UTF8 identifier".
So I'd like to ask you if you can change "false" to "true" in the constructor of UTF8Encoding class in the WriteToDisk method of AddAnyFilePackage.cs (line 159 now). What do you think about it?
Thank you for great extensions!
I'd love to have this extension in VS 2012!
Most of the times the created types are intended to be public
so why not just put it in the templates? I find myself always doing this right after I add the file.
Microsoft Visual Studio Enterprise 2017 RC
Version 15.0.26014.0 D15REL
Microsoft .NET Framework
Version 4.7.02017
Add New File - Version: 3.5.127
Shift-F2 does not work if you use the new 'Open Folder' feature
The 'Add New File' Dialog box does NOT pop-up
Cool new dialog box.
It looks like you can activate the extension by right clicking in the Solution Explorer
window and clicking Add
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.