I have a Visual Studio solution file for a plugin DLL that works just fine when I build locally via VS. It contains a "project" that is a reference to the executable I need to use as my VS startup project in order to debug the plugin:
Project("{911E67C6-3D85-4FCE-B560-20A9C3E3FF48}") = "Paratext", "%ParatextInstallDir%\Paratext.exe", "{64795DCD-9F35-4E20-9A1F-888A6416329A}"
ProjectSection(DebuggerProjectSystem) = preProject
PortSupplier = 00000000-0000-0000-0000-000000000000
Executable = %ParatextInstallDir%\Paratext.exe
RemoteMachine = LSDEV-TBOGLE
StartingDirectory = %ParatextInstallDir%
Environment = Default
LaunchingEngine = fb0d4648-f776-4980-95f8-bb7f36ebc1ee
UseLegacyDebugEngines = No
LaunchSQLEngine = No
AttachLaunchAction = No
IORedirection = Auto
EndProjectSection
EndProject
However, when I build the solution using MSBuild (either locally or on TeamCity), it outputs a warning:
EXEC : warning : Project file C:\Projects\Transcelerator\%ParatextInstallDir%\Paratext.exe cannot be found. [C:\Proje
cts\Transcelerator\build\Transcelerator.proj]
Locally, it can't find it because it is appending the build folder to the start of the path and then (apparently) not expanding the %ParatextInstallDir% environment variable. On TeamCity, this environment variable isn't even defined and the Paratext.exe file does not exist at all. No problem, since for the command-line build I don't care about the existence of that EXE anyway. But in a perfect world, I'd prefer not to have the warning at all.
Is there a way to suppress this warning, either by somehow making the Project conditional within the solution (if it can't be found) OR by some kind of command-line switch or config file entry to tell MSBuild to suppress that warning?
I know I could pass in the projects to build individually on the MSBuild command line, but that would require keeping them in sync whenever "normal" projects are added (or removed). Note that this cannot be controlled using configurations; this external project is already not present in any configuration.
Solution Filter
Create a Solution Filter file that excludes the
Paratextproject. At the command line with MSBuild and under TeamCity with MSBuild, use the .slnf file (and not the .sln file) to build.This approach is essentially creating an alternate view of the solution that doesn't include the
Paratextproject. You describedParatextas a startup for debugging -- so I assume the other projects in the solution do not haveProjectReference's toParatextand will build fine when theParatextproject is not available.Visual Studio and MSBuild
As you observed, the parsing of solution files is different between Visual Studio and MSBuild.
Within Microsoft there are and have been different teams for different parts and pieces of the developer tools. To keep it brief, there is a parser for solution files that is part of Visual Studio but, for reasons, is not shared even within Microsoft. For MSBuild to accept a .sln file on the command line, the team for MSBuild wrote their own code to parse a solution file.