Visual Studio 2012: How to perform a conditional post-build event - macros

How do I perform a conditional post-build event? Specifically, I would like to only execute the post-build event command line for the debug release but not for the release build.
I did not see any way in a project's properties' Build Event page.

You just need to do some checking against the $ConfigurationName property.
This SO post has lots of examples:
How to run Visual Studio post-build events for debug build only

Related

How to make Postbuild events execute in VS Code for a project created in Visual Studio 2022?

I can build my project successfully using "dotnet build" on the VS Code terminal, but I don't see evidence that my Postbuild event took place. It is crucial to make that event's command happen at build time on VS Code if I am to use it instead of Visual Studio 2022. The Postbuild event does occur if I build the project inside Visual Studio 2022 (where it was originally configured). Can I make the Postbuild event execute when running VS Code's "dotnet build" command--or is there some other procedure I must follow to make this project's Postbuild event execute properly from VS Code?

Visual Studio test task fails in pipeline but succeeds in test console

I am using Visual studio test task to run all my tests as a part of my build definition.
The options that I have enabled are as attached below:
Now, the problem here is that, some of my tests always fail when I run them from the build pipleine , however all of these test seem to pass when I run them via
vstests console.exe command.
ex: "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\VSTest.Console" <path to dll>
Does anyone have any clue what could be wrong in here?
Thanks.
Using the Installed by tools installer selection, I would need to see what your tools installation task is doing to provide additional info. Maybe you're not installing a version that is compatible with the tests?
If you don't have a specific need to call out a different test platform version, maybe try using Latest.
OR
Since you're calling ...\Microsoft Visual Studio 14.0\...\VSTest.Console, you may want to select the Visual Studio 2015 option.

VS Code missing global Tasks menu

The current VS Code documentation on integrating with external tools via tasks (Integrate with External Tools via Tasks) refers to the "global Tasks menu", but my latest version 1.27.1 of VS Code has no Tasks menu. In my UI, the Terminal menu has the build tasks under it. Have I done something to change my UI from standard? Is the VS Code documentation out of date?
It's just been renamed to "Terminal":
August 2018 (version 1.27)
[…]
The Tasks menu was renamed to Terminal and some more entries for the Integrated Terminal were added.

Visual Studio Team Services Release Definition - Task to rename a file?

How can I rename a file in a release definition in Visual Studio Team services? Is there a built-in or marketplace task available or otherwise, how can this be achieved?
Answer:
Add the "Inline PowerShell" task from the marketplace
Enter the following PowerShell code in the text area
Param
(
[string]$pathToFileToRename
)
Rename-Item $pathToFileToRename NewName.txt
Enter any required arguments in the arguments text box (you can use environment variables), for example.
pathToFileToRename $(System.DefaultWorkingDirectory)/somepath/CurrentName.txt
Use the Run Command Line task or do it in a PowerShell script and invoke the script in your release.

CodeAnalysis using msbuild does not fail on warning/error

I started down this path of wanting to do code analysis on my solution using msbuild. I was looking at FxCop but it appears to now be part of Visual Studio and from my understanding you need Visual Studio installed on your build agents.
I am calling msbuild from a powershell using the following command;
"$(get-content env:systemroot)\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /tv:4.0 /p:RunCodeAnalysis=Always"
It appears to run the code analysis and output warnings but never fails the build, even after I added <CodeAnalysisTreatWarningsAsErrors>true</CodeAnalysisTreatWarningsAsErrors>
to my .csproj file.
All I want is to run code analysis from msbuild command line and have it fail the build if any warning is found. I understand it can be done in Visual Studio but I need to be able to run this from the command line (with/without VS2013)
Am I missing something? Shouldn't /p:RunCodeAnalysis=Always and setting the CodeAnalysisTreatWarningsAsErrors to true be all that is needed?