VS2017中的DevEnvDir指向VS2015

DevEnvDir in VS2017 points to VS2015

在我的扩展项目文件中,我通过在我的项目文件中设置 StartPrograms(如果重要的话是 .vbproj)

来设置启动操作以启动 Visual Studio
<StartPrograms>$(DevEnvDir)devenv.exe</StartPrograms>

问题是,当项目在 VS2017 中打开时,它会打开 VS2015 并且在项目属性中我看到:

我的项目有问题吗?还是我理解错了 DevEnvDir?

DevEnvDir in VS2017 points to VS2015

那是因为你设置的启动外部程序是Visual Studio2015。并且此信息存储在 .csproj.user 文件中。如果在与项目文件相同的文件夹中打开该 .csproj.user 文件,您将发现以下内容:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
    <StartAction>Program</StartAction>
    <StartProgram>C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe</StartProgram>
  </PropertyGroup>
</Project>

所以,即使你在项目文件中指定StartPrograms,但在项目中指定启动外部程序属性也会覆盖它。

要解决此问题,您应该将启动外部程序指定为 Visual Studio 2017:

C:\Program Files (x86)\Microsoft Visual Studio17\Enterprise\Common7\IDE\devenv.exe

希望对您有所帮助。