I've seen a few posts related to this topic but none with any conclusive answers...
When debugging my VS.NET 2010 app, I'm trying to start an external program whose location is relative to the project path. I've seen some indications that macros (like $(ProjectDir)) were supported in earlier versions of VS.NET, but they don't seem to work in VS.NET 2010. Using relative path notation just gives me an error that the path is invalid.
Has anyone run into this? If so, how did you address?
Thanks.
I know this is a little late to the party, but here's how we do it. The key to this is to set the 'OutputPath' explicitly to the Build directory. This re-bases it to working directory and not the VS install directory.
Update output path for the project to be:<OutputPath>$(MSBuildProjectDirectory)\bin\</OutputPath>
Update StartProgram for the project to be:<StartProgram>$(OutputPath)Relative.exe</StartProgram>
Here is a sample configuration 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>
Similar to what Yobi21 suggested, editing the project file and adding these lines to the main <PropertyGroup>
in the project file worked for me:
<StartAction>Program</StartAction>
<StartProgram>$(MSBuildProjectDirectory)\Path\Relative\To\CSProj\Folder</StartProgram>
<StartArguments>Any Required Arguments</StartArguments>
Watch out for the properties in the
.csproj.user
file overriding those in your regular project file. Note: Starting with Visual Studio 2017, these properties are contained in thelaunchsettings.json
file.
This one stumped me until I deleted the entries.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With