I'm using Visual Studio 2017, C# Class Library Project. I've bunch of code in my post-build event of this project. This project is referenced by unit test project. I don't want to run the post build event codes in case of running unit test project. In the post-build event of my library, how do I identify if the build event is invoked because of running unit test or building the library directly?
Another way I was thinking is, to change the $(ConfigurationName) as UnitTest while executing unit tests. I don't know how to change it for referenced projects dynamically.
Edit: Here is my code in library project's post build event.
cd "$(ProjectDir)"
echo %branch%
if $(ConfigurationName)==Release goto :SKIP
if $(ConfigurationName)==Interactive goto :SKIP
set configfile=$(ProjectDir)Configurations\$(ConfigurationName)-App.config
set sourcedir=$(ProjectDir)$(OutDir)
set destdir=\Program Files\Project\AppServer $(ConfigurationName)\
echo config = %configfile%
echo source = %sourcedir%
echo dest = %destdir%
echo
echo net stop "Application Server $(ConfigurationName)" > %TMP%\$(ConfigurationName)deploy.cmd
echo copy "%sourcedir%*.*" "%destdir%" >> %TMP%\$(ConfigurationName)deploy.cmd
echo copy "%configfile%" "%destdir%AppServer.exe.config" >> %TMP%\$(ConfigurationName)deploy.cmd
echo net start "Application Server $(ConfigurationName)" >> %TMP%\$(ConfigurationName)deploy.cmd
echo pause >> %TMP%\$(ConfigurationName)deploy.cmd
cmd /c elevate %TMP%\$(ConfigurationName)deploy.cmd
goto :EXIT
:SKIP
echo Skipping local deployment for configuration $(ConfigurationName)
:EXIT