I would like to be able to define custom commands/task/macro for a VisualStudio solution. Then I would like to execute that command for a file that is selected in the Solution Explorer.
There are several possibilities to execute the command that would be fine for me:
a) Right click on the file in the Solution Explorer and choose the command from the context menu (my favorite)
b) Select a file in the Solution Explorer. Then click on a button on a tool bar. The command would then somehow retrieve the selected file from the Solution Explorer.
c) Select a file in the Solution Explorer. Then start a task from the Task Runner Explorer. The executed task would somehow retrive the selected file from the 'Solution Explorer'
I tried to use the VisualStudio extension VsCommandBuddy. However, it does not support file specific commands, see
https://github.com/PaulHuizer/VsCommandBuddy/issues/21
I also tried to use a Grunt or Gulp task that can be started from the Task Runner Explorer. However, I don't know how I can pass/access the file that is currently selected in the Solution Explorer.
https://blogs.msdn.microsoft.com/webdev/2016/01/06/task-runners-in-visual-studio-2015/
=> Is there a VisualStudio extension that easily allows to define custom commands for files?
=> How can I pass/access the file that is selected in the SolutionExplorer in script files (e.g. Gulp, Grunt, Webpack)?
=> Any other comfortable work flow that you would recommend?
It would be possible to write my own VisualStudio extension. But I guess that someone else already knows a solution for this.
1. Create an external tool command:
Tools=>External Tools=>Add
Use cmd.exe as Command
Use /c as first entry for `Arguments' and then specify the command line command you want to execute, e.g. grunt
Use the available variables, e.g. $(SolutionDir), $(ItemPath) (=file path), ... to customize your external command
2. Add external command as entry to the context menu of the solution explorer
Tools=>Customize=>Commands
Select Context menu: Project and Solution Context Menu | Item
Add Command...=>Tools=>External Command 1
Run command
Use the new context menu entry for items in the solution explorer
Stop command
In order to cancel/stop an external command, you can also use the context menu of the solution explorer. If the original name of the command is "Test with Karma", the title will be modified to "(Stop) Test with Karma" as long as the command is running. =>Select that entry to stop the command.
Export settings
Unfortunately those settings can not be stored with the Solution (?). It is however possible to export those settings. Then a colleague can import them:
Tools=> Import and export Settings...=>Next
General Settings=> External Tools List and
General Settings=> Menu and Command Bar Customizations
You can use my Visual Commander extension to define a custom command/macro. On how to get the currently selected file in Solution Explorer see In a VS 2015 extension, how can I get the selected object in the Solution Explorer?
Related
When I install PhpStorm from JetBrains Toolbox app I do not have an option to open folders as project when right clicking
Sadly JetBrains Toolbox App does not provide such functionality. Only standalone installer has an option to make them right now. You will have to either use that... or create such entries manually.
https://youtrack.jetbrains.com/issue/TBX-2478 -- watch this ticket (star/vote/comment) to get notified with any progress.
To add an entry to the Windows Explorer's right-click menu:
you can use FileTypesMan by NirSoft or a similar tool.
or create such entry manually, e.g. see this comment for a basic .bat file: https://youtrack.jetbrains.com/issue/IDEA-114307#comment=27-2125363 (at very least it lists Registry keys where to create such an entry).
I found this from Jet Brains :
Click Open on the Welcome screen or select File | Open from the main menu.
In the Select Path dialog, select the directory that contains the project to open.
Drag the desired project from your file chooser right to the Open Project dialog without locating it there. The respective file in the dialog will be found automatically.
Specify whether you want to open the project in a new window, close the current project and reuse the existing window, or open the new project in the same window with the current one. Refer to the Opening multiple projects section for details.
and for the command line you could use this :
<PhpStorm> <path_to_the_project folder>
See Open files from the command line for more information.
I would need a folder to be shared on the server and InDesign CS6 would need to load the scripts from that particular location.
Is this possible?
If you just want to include other scripts in your script you can do this:
$.evalFile(new File(mainscriptloc + "/c/some/folder/central.jsx"));
It will load central.jsx into the executing script just like an "include" file.
On a Mac? I found this solution useful:
http://tewha.net/2012/07/make-a-symbolic-link-from-finder/
The best way I found is to create a folder in any place you want your scripts to be (like a server) which is shared with all the users. Then to setup and run the scripts will be more tricky:
Open ExtendScript Toolkit
Open "Scripts" tab
Click on the top-right button and "Add Favorite"
Choose your path to the script and click ok
Now you can click on the drop down on the left and select "Favorites"
Click on the right drop down and click on your folder name
Double click on your script and run it
Now you are running scripts directly from the custom folder.
The startup script cannot be run from there... so it only works with scripts.
We create links in the users individual scripts folders that link back to the actual script in the central repository on Windows. The downside is of course that users will reasonable often accidentally copy the actual script, rather than a link to the script - and then they miss out on future updates to the script.
Below is an example of a typical users 'scripts panel' folder. Each of the shown shortcuts point at a file in our central repository.
When the user opens InDesign these shortcuts appear in their scripts panel the same way a regular script file would.
On a Mac, I suggest using symlinks (a special kind of OSX shortcut - go here for instructions and an Automator workflow download that will create one whenever you need it).
To create a shortcut, simply select the desired folder (recommended) or file located elsewhere on your computer/server and run the workflow (I suggest making a keyboard shortcut to the workflow as described in the instructions). Drag the shortcut created into your inDesign scripts folder and it will appear and operate exactly as the actual script or folder would in your Scripts Panel. Simply click on the link and inDesign will do the rest - you'll never know what you clicked is not the actual folder/file or that it's located elsewhere.
Note: if you create a shortcut to a script file rather than a folder, be sure to remove the extra text the workflow adds to the name (ie. when applied to "MyScript.jsx", the workflow will create a shortcut named "MyScript.jsx symlink". Remove the " symlink" part so inDesign will recognize the shortcut as a script file. Otherwise it will not run).
I've tested this with inDesign CC on my Mac and it works flawlessly.
Usually, visual studio puts output files to bin/debug or bin/release.
When solution contains a large number of projects its not easy to modify each project output manually.
Also edits in csproj files no desirable, because some of them is shared between solutions..
My questions: Is anybody knows a tool, which can quickly configure output path ?
UPDATE: my problem solved by TFS Build
Presumably you have at least one project in each solution that is unique to that solution. In the Post-Build event of that, copy the contents of each project's output to the required location.
We often to this using a batch file. It's crude but effective. In our project that's unique to the solution we create a Release.bat file. This contains a number of file copies to copy all of the required components from the various output directories of the other projects. You can then just run the batch file in the post build event. We usually copy everything to a "Latest Release" fodler when the solution is built. If this becomes a proper release we will rename the Latest Release folder to the actual release number.
If you have multiple build configurations, or even just use the Debug and Release configurations, you can use an If statement in the Post-Build event to decide which batch file to run. So you could create a Debug.bat, Release.bat etc which do what you need. It can be tedious to set them up and get them working correctly at first, but they are very useful once fully implemented.
Customize your project using the msbuild properties which you can do if you follow these steps:
Go to the solution explorer and unload one project by right clicking on it and select Unload Project.
Then right click again on the unloaded project and select Edit Project. This will open the XML definition of your project, and you will have intellisense for the layout which will help you perform the next steps.
In the visual studio editor find the first PropertyGroup tag and add these lines near or at the end of the closing PropertyGroup tag:
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<BuildDirectory Condition="$(BuildDirectory) =='' or $(BuildDirectory) == '*Undefined*'">$(SolutionDir)\build\</BuildDirectory>
The above SolutionDir is defined in msbuild properties which you can obtain using this answer: msbuild script using solution information and also check out the well known msbuild properties here
The next step is to find the OutputPath tag for each configuration and edit it like this:
<OutputPath>$(BuildDirectory)\x86\AutomatedDebug\</OutputPath>
The example above assumes you have a configuration named AutomatedDebug with destination platform x86.
The output will be
x:\projects\whereever-your-solution-is\build\x86\AutomatedDebug\
Repeat for each project.
To unload more than one project, collapse all projects in the solution explorer and shift click or ctrl click to select all or some projects, then right click on the selected group to unload, unfortunately you cannot do this for editing, at least in visual studio 2010.
I am the first to admit that this is somewhat cumbersome to do for existing projects, but you could easily create a visual studio project template that has these settings changed so that new projects will use a more convenient default output directory.
You cannot edit the output directory directly in visual studio because the project properties editor escapes any $() enclosed text.
Also you could only modify the OutputPath using the name of a system environment variable enclosed in $(). This last option is to enable a global output directory.
If you build any single project modified in this way using msbuild directly in the commandline the output directory will be created one directory above from where you ran msbuild
..\build\x86\AutomatedDebug
If you are in a team, you should warn them not to edit the output directory directly by hand, as this action will overwrite any customization.
Hope this info is useful.
Greetings.
I've tried looking for command line options etc. I'm trying to lower the time I have to wait to see if a build fails due to stylecop.
This option does not appear in any context menus or the tools menu: Is it possible to run StyleCop on just 1 file in a project?
The following context menus should contain commands for running StyleCop:
At solution item in Solution Explorer (rescans the entire solution)
At project item in Solution Explorer (rescans a project)
At any single .cs file in Solution Explorer (scans single file)
Inside text editor of any single .cs file (scans single file)
By the way, which StyleCop version do you use?
Have you considered any issues about wrong installation?
I've created a one-line batch file to run SqlMetal to regenerate a LINQ to SQL DataContext for my database; this works great.
Refresh_DataContext.bat:
"C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\sqlmetal.exe"
/server:.\sqlexpress /database:MyDatabaseName
/code:"%~dp0\DataContext.vb" /context:DataContext
/views /functions /sprocs /pluralize
So far I can run this by opening the enclosing folder in Explorer and running the batch file, and I've also added it to the Tools menu (Tools/External Tools.../Add).
Now I'd like to run this batch file whenever I build (in certain configurations). How do I do this?
What you seem to be looking for can be found under "Pre-build event command line" under your project's properties. Click the "Build Events" tab, and you'll have a little space to enter in a command line which does what you want.
Doh! Of course. Web Application projects have pre- and post- build events; Web Site projects don't.