When I do a build from Visual Studio, on post-build I execute a PowerShell script from MSBuild using the PowerShell MSBuild Task (http://powershellmsbuild.codeplex.com/). In this PowerShell code I would like to add/modify items to my project using Visual Studio automation (through the EnvDTE object).
The exact case is:
For each X.asmx file in my project I need to add Xwsdl.aspx and Xdisco.aspx file that don't need compilation. I only want to do this if these files are not generated yet, or if the asmx file is newer than the current Xwsdl.aspx and Xdisco.aspx files. In case you wonder why I need these additional files: it's a SharePoint thing.
Addition:
Just added the following PowerShell code in the executed script:
$process = [System.Diagnostics.Process]::GetCurrentProcess() Write-Host "Process name: $($a.ProcessName)"
Which returns:
Process name: devenv
Which means that msbuild is executed in the context of the Visual Studio process.