我看过一些与此主题相关的帖子,但没有任何确定的答案......
在调试我的 VS.NET 2010 应用程序时,我试图启动一个位置相对于项目路径的外部程序。我已经看到一些迹象表明 VS.NET 的早期版本支持宏(如 $(ProjectDir)),但它们似乎在 VS.NET 2010 中不起作用。使用相对路径表示法只会给我一个错误,即路径无效。
有没有人遇到过这个?如果是这样,你是如何解决的?
谢谢。
最佳答案
我知道这对派对来说有点晚了,但我们是这样做的。关键是将“OutputPath”显式设置为 Build 目录。这将它重新定位到工作目录而不是 VS 安装目录。
<OutputPath>$(MSBuildProjectDirectory)\bin\</OutputPath>
<StartProgram>$(OutputPath)Relative.exe</StartProgram>
这是一个示例配置 PropertyGroup:
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == '0-Local|AnyCPU'">
<!-- default values you should already have in your csproj -->
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<!-- actual output path and start action definition -->
<OutputPath>$(MSBuildProjectDirectory)\bin\</OutputPath>
<StartAction>Program</StartAction>
<StartProgram>$(OutputPath)NServiceBus.Host.exe</StartProgram>
<StartArguments>NServiceBus.Integration</StartArguments>
</PropertyGroup>
关于visual-studio-2010 - 在 VS.NET 2010 中使用 "Start external program"的相对路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4774745/