Is there any way to ask msbuild what build targets provided msbuild file support? If there is no way to do it in command prompt? May be it could be done programmatically?
Are there no way to do it besides parsing msbuild XML?
A target element can have both Inputs and Outputs attributes, indicating what items the target expects as input, and what items it produces as output. If all output items are up-to-date, MSBuild skips the target, which significantly improves the build speed. This is called an incremental build of the target.
Defines the steps in the standard build process for Visual Basic and C# projects. Defines the steps in the standard build process for Visual C# projects. Defines the steps in the standard build process for Visual Basic projects.
When multiple ItemGroup elements are used, items are combined into a single ItemGroup . For example, some items might be included by a separate ItemGroup element that's defined in an imported file. ItemGroups can have conditions applied by using the Condition attribute.
If MSBuild determines that any output files are out of date with respect to the corresponding input file or files, then MSBuild executes the target. Otherwise, MSBuild skips the target. After the target is executed or skipped, any other target that lists it in an AfterTargets attribute is run.
Certainly MS provides the api to do this without parsing the xml yourself. Look up microsoft.build.buildengine
Adapted from some C# code found on msdn ... it's usually worth exploring. Need to reference the microsoft.build.engine dll for this to compile. Replace framework version and path below with your values. This worked on a sample project file, although the list may be longer than you expect.
using System; using Microsoft.Build.BuildEngine; class MyTargets { static void Main(string[] args) { Engine.GlobalEngine.BinPath = @"C:\Windows\Microsoft.NET\Framework\v2.0.NNNNN"; Project project = new Project(); project.Load(@"c:\path\to\my\project.proj"); foreach (Target target in project.Targets) { Console.WriteLine("{0}", target.Name); } } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With