如何在启用visual studio环境的情况下运行SublimeText [英] How to run SublimeText with visual studio environment enabled

查看:342
本文介绍了如何在启用visual studio环境的情况下运行SublimeText的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

OVERVIEW



现在我在Windows任务栏上有这两个程序:




  • SublimeText3目标:

     D:\software\SublimeText 3_x64 \sublime_text.exe


  • VS2015 x64本地工具命令提示符目标:

     %comspec%/ kC:\Program Files(x86)\Microsoft Visual Studio 14.0 \VC\vcvarsall.bat amd64 




这里的目标是运行Sublime Text启用vs2015环境。


  1. 一个选项将打开vs命令提示符,然后从那里运行升级文本, > sublime_text (这不是很好,我希望它是一个非互动过程

  2. 另一个选择是修改某种方式来自任务栏的sublimetext符号链接目标,所以我可以打开升华与vs2015环境启用,只需点击图标

QUESTION



我可以如何选择2?



NS:我想要获得Sublime Text 3来运行vcvarsall .bat在启动时只适用一次(不在任何构建系统的构建时间)



ATTEMPTS



我第一次尝试了解如何执行bat文件,所以我测试了
一些基本的批处理文件:




  • bat1.bat:它成功打开崇高的文本

      sublime_text 


  • bat2.bat:它成功打开vs命令提示符,并等待用户键入命令

      cmd / kC: \\ Program Files(x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.batamd64 


  • bat3.bat:打开vs命令提示符,但它不会打开ST,除非在命令提示符显示时键入exit

     %comspec%/ kC:\Program Files(x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.batamd64 
    sublime_text


  • bat4.bat:打开vs命令提示符,但它不打开ST,与bat3.bat相同的情况

     %comspec%/ kC:\Program Files(x86)\Microsoft Visual Studio 14.0 \VC \vcvarsall。蝙蝠amd64&& sublime_text 


  • bat5.bat:打开vs命令提示符,但不打开ST,同样case蝙蝠{4,3} .bat

     %comspec%/ kC:\Program Files(x86) \Microsoft Visual Studio 14.0\VC\vcvarsall.batamd64& sublime_text 




在这些尝试后,我决定阅读一些文档试图找到关于 cmd 的一些提示,但没有任何区别。另一个想法是使用conemu自定义任务,例如:

  {vs2015 }:cmd.exe / kC:\Program Files(x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.batamd64& sublime_text 

然后有一个bat文件调用conemu这样:

  D:\software\ConEmuPack.151205\ConEmu64.exe / single -cmd {vs2015} 

结果是+/-我想要的,但是会产生2个终端和一个新的崇高的会话。我正在寻找的只是打开一个适合环境的SublimeText会话,所以我认为这不是一个很好的解决方案,另外,它需要安装conemu。



在所有这些尝试之后,我想也许使用python打开一个命令提示符,并键入&运行神奇一些命令可能会有帮助,但我不知道如何做。



结论:直到问题仍未解决的日期...

解决方案


  1. 完全如所述不可能直接,但Sublime Text具有运行其他程序的选项。

创建一个到目录的批处理文件vcvarsall.bat想要(它查看从它运行的目录,所以它需要从适当的目录启动),并运行vcvarsall.bat:

  @ECHO OFF 
REM vcdir是您应该是
的目录设置vcdir =c:\program文件(x86)\ Microsoft Visual Studio 14.0 \VC
REM进入该目录
推%vcdir%
REM运行vcvarsall.bat设置env vars
调用vcvarsall.bat amd64
REM回到我们最初的目录
popd

如果你可以运行构建过程中的这个批处理文件(如果你只需要它的构建过程,你不介意每次重新运行它),然后按照这些说明将该批处理文件添加到升华文本中的构建设置3



更优雅的方法是了解如何使Sublime Text 3在启动时(而不是在构建时)仅运行一次程序。我会赌钱是可能的,但我现在需要重新开始工作...


OVERVIEW

Right now I got these 2 programs on my windows taskbar:

  • SublimeText3 target:

    "D:\software\SublimeText 3_x64\sublime_text.exe"
    

  • VS2015 x64 Native Tools Command Prompt target:

    %comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"" amd64
    

Goal here is running Sublime Text with vs2015 environment enabled.

  1. One option would be open the vs command prompt and then run sublime text from there, > sublime_text (this is not good one, I want it to be a non-interactive process)
  2. Another option would be modifying somehow the sublimetext symlink target from the taskbar so I could open sublime with vs2015 environment enabled just clicking the icon

QUESTION

How could I acomplish option 2?

NS: I want to get Sublime Text 3 to run vcvarsall.bat properly only once at startup (not at build time on any build system)

ATTEMPTS

My first attempt was trying to understand how bat files executed so I tested some basic batch files:

  • bat1.bat: It opens sublime text succesfully

    sublime_text
    

  • bat2.bat: It opens vs command prompt succesfully and it waits for user to type commands

    cmd /k ""C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"" amd64
    

  • bat3.bat: Open vs command prompt but it won't open ST, unless you type exit once the command prompt is shown

    %comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"" amd64
    sublime_text
    

  • bat4.bat: Open vs command prompt but it doesn't open ST, same case than bat3.bat

    %comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"" amd64 && sublime_text
    

  • bat5.bat: Open vs command prompt but it doesn't open ST, same case than bat{4,3}.bat

    %comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"" amd64 & sublime_text
    

After these attempts I've decided to read some docs trying to find some hints about cmd but it didn't make any difference.

Another idea was using conemu customized tasks, something like:

{vs2015}: cmd.exe /k "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64 & sublime_text

and then having a bat file calling conemu like this:

D:\software\ConEmuPack.151205\ConEmu64.exe /single -cmd {vs2015}

the result was +/- what I wanted, but 2 terminals and a new sublime session would be spawned. What I'm looking for is just opening a SublimeText session with the right environment, so I consider this not a good solution, plus, it requires to have conemu installed.

After all those attempts I thought maybe using python to open a command prompt and typing&running "magically" some commands could be helpful but I don't know how to do it.

Conclusion: Till the date the problem remains unsolved...

解决方案

  1. exactly as stated is not possible directly but Sublime Text has options for running other programs.

Make a batch file that goes to the directory that vcvarsall.bat wants (it looks at the directory it was run from, so it needs to be started from the proper dir) and runs vcvarsall.bat:

@ECHO OFF
REM vcdir is the directory where you should be
set vcdir="c:\program files (x86)\Microsoft Visual Studio 14.0\VC"
REM go into that directory
push "%vcdir%"
REM Run vcvarsall.bat to set the env vars
call vcvarsall.bat amd64
REM Get back to the directory we were in initially
popd

If you're ok running this batch file during build (if you only need it for the build process and you don't mind rerunning it every time) then follow these instructions to add that batch file to your build settings in sublime text 3

A more elegant approach would be to find out how to get Sublime Text 3 to run a program just once on startup (rather than at build time). I'd bet money that's possible, but I need to get back to work now...

这篇关于如何在启用visual studio环境的情况下运行SublimeText的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆