PageRenderTime 52ms CodeModel.GetById 46ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/BuildTools/MSBuildCommunityTasks/Sample.proj

http://github.com/icsharpcode/ILSpy
Unknown | 153 lines | 127 code | 26 blank | 0 comment | 0 complexity | 44d5361843a7b1683111d6041ced1f09 MD5 | raw file
  1<?xml version="1.0" encoding="utf-8"?>
  2<Project DefaultTargets="All"  xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  3  <!-- Required Import to use MSBuild Community Tasks -->
  4  <Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>
  5  
  6  <!-- These are sample targets the demonstrate the use of MSBuild Community Tasks  -->
  7  <Target Name="AssemblyInfo">    
  8    <AssemblyInfo CodeLanguage="CS"  
  9			OutputFile="AssemblyInfo.cs" 
 10			AssemblyTitle="AssemblyInfoTask" 
 11			AssemblyDescription="AssemblyInfo Description"
 12			AssemblyConfiguration=""
 13			AssemblyCompany="Company Name, LLC"
 14			AssemblyProduct="AssemblyInfoTask"
 15			AssemblyCopyright="Copyright (c) Company Name, LLC 2005"
 16			AssemblyTrademark=""
 17			ComVisible="false"
 18			CLSCompliant="true"
 19			Guid="d038566a-1937-478a-b5c5-b79c4afb253d"
 20			AssemblyVersion="1.0.0.0" 
 21			AssemblyFileVersion="1.0.0.0" />
 22  </Target>
 23
 24  <Target Name="Math">
 25    <Add Numbers="4;3">
 26      <Output TaskParameter="Result" PropertyName="Result" />
 27    </Add>
 28    <Message Text="Add 4+3= $(Result)"/>
 29
 30    <Add Numbers="4;3;7">
 31      <Output TaskParameter="Result" PropertyName="Result" />
 32    </Add>
 33    <Message Text="Add 4+3+7= $(Result)"/>
 34
 35    <Subtract Numbers="10;3">
 36      <Output TaskParameter="Result" PropertyName="Result" />
 37    </Subtract>
 38    <Message Text="Subtract 10-3= $(Result)"/>
 39
 40    <Multiple Numbers="10;3">
 41      <Output TaskParameter="Result" PropertyName="Result" />
 42    </Multiple>
 43    <Message Text="Multiple 10*3= $(Result)"/>
 44
 45    <Divide Numbers="1;2">
 46      <Output TaskParameter="Result" PropertyName="Result" />
 47    </Divide>
 48    <Message Text="Divide 1/2= $(Result)"/>
 49
 50  </Target>
 51
 52  <Target Name="Version">
 53    <Version VersionFile="version.txt" RevisionType="Increment">
 54      <Output TaskParameter="Major" PropertyName="Major" />
 55      <Output TaskParameter="Minor" PropertyName="Minor" />
 56      <Output TaskParameter="Build" PropertyName="Build" />
 57      <Output TaskParameter="Revision" PropertyName="Revision" />
 58    </Version>
 59
 60    <Message Text="Version: $(Major).$(Minor).$(Build).$(Revision)"/>
 61  </Target>
 62
 63  <Target Name="Registry">
 64    <RegistryRead 
 65			KeyName="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework" 
 66			ValueName="InstallRoot">
 67      <Output TaskParameter="Value" PropertyName="InstallRoot" />
 68    </RegistryRead>
 69    <Message Text="InstallRoot: $(InstallRoot)"/>
 70
 71    <RegistryWrite 
 72			KeyName="HKEY_CURRENT_USER\SOFTWARE\MSBuildTasks"
 73			ValueName="RegistryWrite"
 74			Value="Test Write" />
 75
 76  </Target>
 77
 78  <Target Name="Service">
 79    <ServiceQuery ServiceName="w3svc">
 80      <Output TaskParameter="Status" PropertyName="Status" />
 81    </ServiceQuery>
 82    <Message Text="Web Server: $(Status)"/>
 83
 84    <ServiceController ServiceName="w3svc" Action="Restart" />
 85
 86  </Target>
 87
 88  <Target Name="WebDownload">
 89    <WebDownload FileUri="http://www.microsoft.com/default.aspx" 
 90			FileName="microsoft.html" />
 91  </Target>
 92
 93  <Target Name="Attrib" DependsOnTargets="Version">
 94    <Attrib Files="version.txt" 
 95      ReadOnly="true" Hidden="true" System="true"/>
 96
 97    <Attrib Files="version.txt" 
 98      Hidden="false" System="false"/>
 99
100    <Attrib Files="version.txt" 
101      Normal="true"/>
102
103  </Target>
104
105  <PropertyGroup>
106    <Code>
107      <![CDATA[
108			public static void ScriptMain() {
109				List<string> list = new List<string>();
110				list.Add("Happy");
111				list.Add("New");
112				list.Add("Year");
113				Console.WriteLine("Hello MSBuild Community Scripting World.");
114				foreach(string s in list)
115				{
116				  Console.WriteLine(s);
117				}
118			}
119			]]>
120    </Code>
121  </PropertyGroup>
122
123  <Target Name="Script">
124    <Script Language="C#" Code="$(Code)" />
125  </Target>
126
127  <Target Name="Sleep">
128    <Message Text="Sleep: 200"/>
129    <Sleep Milliseconds="200" />
130  </Target>
131  
132  <ItemGroup>
133    <ZipFiles Include="**\*.*" Exclude="" />
134  </ItemGroup>
135  
136  <Target Name="Zip">
137    <Zip Files="@(ZipFiles)" 
138			ZipFileName="Sample.zip" />
139  </Target>
140
141  <Target Name="All">
142    <CallTarget Targets="AssemblyInfo" />
143    <CallTarget Targets="Math" />
144    <CallTarget Targets="Version" />
145    <CallTarget Targets="Registry" />
146    <CallTarget Targets="Service" />
147    <CallTarget Targets="WebDownload" />
148    <CallTarget Targets="Attrib" />
149    <CallTarget Targets="Script" />
150    <CallTarget Targets="Sleep" />
151    <CallTarget Targets="Zip" />
152  </Target>
153</Project>