" ' devenv的'不被视为内部或外部命令......"

时间:2016-06-01 21:59:40

标签: visual-studio command-prompt devenv

有没有办法从命令提示符中打开VS项目?例如,使用Atom的方式,您可以导航到您要打开的文件夹并运行" atom ." VS存在这种效用吗?

修改:相当于" C:\> devenv /run SomeSolution.sln" ?

如果是的话,太棒了!但似乎仍有一个问题,因为我认为" devenv"命令至少应该被识别,但我目前得到

  

' devenv的'不被视为内部或外部命令,   可操作程序或批处理文件。

我看到了一个S / O贡献者recommended adding

  

C:\ Program Files(x86)\ Microsoft Visual Studio   10.0 \ Common7 \ IDE \ devenv.exe的

到每个MSDN的PATH环境变量值,如this,我做了,但我收到相同的消息。

任何人都可以解释可能发生的事情以及如何解决这个问题吗?感谢

5 个答案:

答案 0 :(得分:8)

您需要添加现有路径值的新路径。

完整解决方案:

  1. 转到MyComputer >> Properties >> Change Settings >> Advanced >> Environmental variables

  2. 点击底部窗格中的路径值,然后点击修改

  3. 为devenv.exe 文件夹位置添加新路径。 对我而言,这是“D:\ Program Files \ Microsoft Visual Studio Community 2017 \ Common7 \ IDE \”

答案 1 :(得分:2)

这比它看起来容易得多。转到项目的根目录,键入(define (stream-pairs s) (define (iter s save) (stream-append (stream-map (lambda (x) (stream-cons (stream-first s) x)) save) (iter (stream-rest s) (stream-cons save (stream-first s))))) (iter s empty-stream)) (define A (stream-cons 1 (scale-stream 2 A))) (define C (stream-pairs A)) 文件的名称,然后按Enter键。 Windows知道如何使用注册表o根据您运行的文件的扩展名查找.sln

例如:

devenv.exe

此技术与在资源管理器中双击打开sln文件相同。

答案 2 :(得分:2)

在类似的问题上,对于VS 2017,我想构建一个解决方案,以下工作正常:

call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\devenv.exe" Project.sln /build

答案 3 :(得分:0)

VS 2019社区

static QString toString(HRESULT hr)
{
     _com_error err{hr};
     const TCHAR* lastError = err.ErrorMessage();
     return QStringLiteral("Error 0x%1: %2").arg((quint32)hr, 8, 16, QLatin1Char('0'))
            .arg(lastError);
}

static QString getLastErrorMsg()
{
     DWORD lastError = GetLastError();
     QString s = toString(HRESULT_FROM_WIN32(lastError));
     return s;
}

BOOL FileExists(LPCWSTR szPath)
{
     DWORD dwAttrib = GetFileAttributes(szPath);

     return (dwAttrib != INVALID_FILE_ATTRIBUTES &&
             !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY));
}

// not used
static const wchar_t* toLPCWSTR(QString s)
{
     std::wstring dstWString = s.toStdWString();
     const wchar_t* localC_src = dstWString.c_str();
     return localC_src;
}

static bool DirExists(LPCWSTR szPath)
{
     DWORD ftyp = GetFileAttributes(szPath);
     if (ftyp == INVALID_FILE_ATTRIBUTES)
          return false;  //something is wrong with your path!

     if (ftyp & FILE_ATTRIBUTE_DIRECTORY)
          return true;   // this is a directory!

     return false;    // this is not a directory!
}

BackupResult BackupManager::copyFile(QString m_src, QString m_dst)
{
     QFileInfo fi(m_src);
     QString dir = fi.dir().path();
//     const wchar_t* dirC = toLPCWSTR(dir);
     QString src = QString(m_src).replace("/", "\\");
     QString dst = QString(m_src).replace("/", "\\");
//     const wchar_t* localC_src = toLPCWSTR(src);
//     const wchar_t* localC_dst = toLPCWSTR(dst);
     LPCWSTR localC_src = (LPCWSTR) src.utf16();
     LPCWSTR localC_dst = (LPCWSTR) dst.utf16();
     LPCWSTR dirC = (LPCWSTR) dir.utf16();

     auto rc = CopyFileExW(localC_src, localC_dst, &BackupManager::copyProgress, this, &bStopBackup, 0);
     if (rc == 0) {

          DWORD lastError = GetLastError(); // Error = 0x32
          bool dirExist = DirExists(dirC); // true
          bool fileExists = FileExists(localC_src); // true

          printWarning(TAG, QString("File Copy Error: %1").arg(getLastErrorMsg()));
#ifdef QT_DEBUG
          if (FileExists(localC_src)) {
               qDebug() << "#FailedCopy: Windows file exists but copy failed" << src; // this gets hit using the implemented c-style cast 
          }
          else {
               if (QFile::exists(src)) {
                    qDebug() << "#FailedCopy: Windows is really being full of shit! " << src;   // this always gets triggered when using QString::toStdWString.c_str()
               }
               else {
                    qDebug() << "#FailedCopy: Windows file copy failed outright" << src;
               }
          }
#endif
          // copy failed
          return BackupResult::IOError;
     }

     // copy success
     return BackupResult::Success;
}

任何Visual Studio版本

要查找与VS复制/版本无关的特定devenv.exe路径,可以使用 cmd ,然后运行:

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\devenv.exe

cd \

注意:命令dir /s divenv.exe可能需要几分钟才能找到。

答案 4 :(得分:0)

由于我不想更新PATH变量,因此我使用了以下步骤在命令提示符下运行devenv

  1. 导航到“开始”菜单上的Visual Studio快捷方式
  2. 右键单击快捷方式
  3. 点击属性
  4. 复制目标中显示的路径。这是您使用的devenv版本的路径。
  5. 将复制的路径粘贴到命令提示符中,然后按Enter键