TL;DR
Can I have a Visual Studio pre-build event that skips the build of a project without a visual error?
Details
I have a project that contains a custom XML file and a Powershell script that generates a resource file from the XML during pre-build
event.
My goal is to only build the project if there are changes to the XML file. I can already determine if the file has changed, but I can't inform Visual Studio to skip the build. Either I stop the script with an exit code of 0
(which lets the build continue) or any other number (which shows an ugly error in the Error List).
Can I have a pre-build
script decide whether to build or skip the project?
Example
# Check to see if the current file is different from the file copied during build.
if((Test-Path $buildXmlFile) -and (Compare-Object -ReferenceObject (Get-Content $projectXmlFile) -DifferenceObject (Get-Content $buildXmlFile))){
Write-Host "Changes found! Rebuilding!"
} else {
Write-Host "No changes found! Skipping Build"
# Exit 0 will cause it to still build...
# Exit -1, Exit 1, etc. will cause a big error to show...
# HOW DO I SKIP???
}