MSBuild.Community.Tasks
Installs and register script mappings for ASP.NET
Install the latest version of ASP.NET on the server:
<InstallAspNet />
Generates an AssemblyInfo files
Generates a common version file.
<AssemblyInfo CodeLanguage="CS"
OutputFile="VersionInfo.cs"
AssemblyVersion="1.0.0.0"
AssemblyFileVersion="1.0.0.0" />
Generates a complete version file.
<AssemblyInfo CodeLanguage="CS"
OutputFile="$(MSBuildProjectDirectory)\Test\GlobalInfo.cs"
AssemblyTitle="AssemblyInfoTask"
AssemblyDescription="AssemblyInfo Description"
AssemblyConfiguration=""
AssemblyCompany="Company Name, LLC"
AssemblyProduct="AssemblyInfoTask"
AssemblyCopyright="Copyright (c) Company Name, LLC 2006"
AssemblyTrademark=""
ComVisible="false"
CLSCompliant="true"
Guid="d038566a-1937-478a-b5c5-b79c4afb253d"
AssemblyVersion="1.0.0.0"
AssemblyFileVersion="1.0.0.0" />
Generates a complete version file for C++/CLI.
<AssemblyInfo CodeLanguage="CPP"
OutputFile="$(MSBuildProjectDirectory)\Properties\AssemblyInfo.cpp"
AssemblyTitle="MyAssembly"
AssemblyDescription="MyAssembly Description"
AssemblyConfiguration="$(Configuration)"
AssemblyCompany="Company Name, LLC"
AssemblyProduct="MyAssembly"
AssemblyCopyright="Copyright (c) Company Name, LLC 2008"
AssemblyTrademark=""
ComVisible="false"
CLSCompliant="true"
Guid="d038566a-1937-478a-b5c5-b79c4afb253d"
AssemblyVersion="1.0.0.0"
AssemblyFileVersion="1.0.0.0"
UnmanagedCode="true" />
Changes the attributes of files and/or directories
Make file Readonly, Hidden and System.
<Attrib Files="Test\version.txt"
ReadOnly="true" Hidden="true" System="true"/>
Clear Hidden and System attributes.
<Attrib Files="Test\version.txt"
Hidden="false" System="false"/>
Make file Normal.
<Attrib Files="Test\version.txt"
Normal="true"/>
Describes certain byte measurements as nice strings.
The developer of this task did not add an example in the summary documentation.
Provides information about the build computer.
Get build computer information.
<Computer>
<Output TaskParameter="Name" PropertyName="BuildMachineName" />
<Output TaskParameter="IPAddress" PropertyName="BuildMachineIPAddress" />
<Output TaskParameter="IPAddressV4" PropertyName="BuildMachineIPAddressV4" />
<Output TaskParameter="OSPlatform" PropertyName="BuildMachineOSPlatform" />
<Output TaskParameter="OSVersion" PropertyName="BuildMachineOSVersion" />
</Computer>
A task to play the sound of a beep through the console speaker.
To play the sound of a beep at a frequency of 800 hertz and for a duration of 200 milliseconds, use
<Beep />
Delete a directory tree. This task supports wild card directory selection.
Delete all bin and obj directories.
<DeleteTree Directories="**\bin;**\obj" />
Delete all bin and obj directories that start with MSBuild.Community.
<DeleteTree Directories="MSBuild.Community.*\**\bin;MSBuild.Community.*\**\obj" />
Reads a set of project files (.csproj, .vbproj) in InputFiles and generate a GraphViz style syntax. You can paste the result of the graphs in places like http://graphviz-dev.appspot.com/ to see your chart or run the file using the GraphViz tool http://www.graphviz.org/
<ItemGroup>
<Dependency Include="Project01.csproj" />
</ItemGroup>
<Target Name="Default">
<DependencyGraph InputFiles="@(Dependency)" IsIncludeProjectDependecies="true" ExcludeReferences="^System" />
</Target>
Result: digraph { subgraph ProjectReferences { node [shape=box]; "{4993C164-5F2A-4831-A5B1-E5E579C76B28}" [label="Project01"]; "{1B5D5300-8070-48DB-8A81-B39764231954}" [label="Project03"]; "{E7D8035C-3CEA-4D9C-87FD-0F5C0DB5F592}" [label="Project02"]; "{7DBCDEE7-D048-432E-BEEB-928E362E3063}" [label="Project03"]; } "{4993C164-5F2A-4831-A5B1-E5E579C76B28}" -> "Microsoft.CSharp"; "{1B5D5300-8070-48DB-8A81-B39764231954}" -> "Microsoft.CSharp"; "{E7D8035C-3CEA-4D9C-87FD-0F5C0DB5F592}" -> "Microsoft.CSharp"; "{7DBCDEE7-D048-432E-BEEB-928E362E3063}" -> "Microsoft.CSharp"; "{4993C164-5F2A-4831-A5B1-E5E579C76B28}" -> "{1B5D5300-8070-48DB-8A81-B39764231954}"; "{4993C164-5F2A-4831-A5B1-E5E579C76B28}" -> "{E7D8035C-3CEA-4D9C-87FD-0F5C0DB5F592}"; "{E7D8035C-3CEA-4D9C-87FD-0F5C0DB5F592}" -> "{7DBCDEE7-D048-432E-BEEB-928E362E3063}"; }
Very simple parser that gets reference and assembly name information from project files
The developer of this task did not add an example in the summary documentation.
Base class for all references
The developer of this task did not add an example in the summary documentation.
Represents an assembly reference inside a project file
The developer of this task did not add an example in the summary documentation.
Represents a project reference inside a project file
The developer of this task did not add an example in the summary documentation.
A task for embedded native resource.
The developer of this task did not add an example in the summary documentation.
Uploads a group of files using File Transfer Protocol (FTP).
Upload a file.
<FtpUpload
LocalFile="MSBuild.Community.Tasks.zip"
RemoteUri="ftp://localhost/" />
Upload all the files in an ItemGroup:
<FtpUpload
Username="username"
Password="password"
UsePassive="true"
RemoteUri="ftp://webserver.com/httpdocs/"
LocalFiles="@(FilesToUpload)"
RemoteFiles="@(FilesToUpload->'%(RecursiveDir)%(Filename)%(Extension)')" />
Describes a factory for IFtpWebRequest.
The developer of this task did not add an example in the summary documentation.
This class references an interface that looks like FtpWebRequest in order to support unit testing without an actual FTP Server.
The developer of this task did not add an example in the summary documentation.
An adapter to make the real FtpWebRequest look like an IFtpWebRequest.
The developer of this task did not add an example in the summary documentation.
Ftp client base class.
The developer of this task did not add an example in the summary documentation.
Creates a full remote directory on the remote server if not exists using the File Transfer Protocol (FTP). This can be one directory or a full path to create.
Create remote directory:
<FtpCreateRemoteDirectoty
ServerHost="ftp.myserver.com"
Port="42"
RemoteDirectory="Directory\Subdirectory\MyOtherSubdirectory"
Username="user"
Password="p@ssw0rd"
/>
Determ if a remote directory exists on a FTP server or not.
Determ of Directory\1 exists:
<Target Name="CheckIfDirectoryExists">
<FtpDirectoryExists
ServerHost="ftp.myserver.com"
Port="42"
RemoteDirectory="1\2\3"
Username="user"
Password="p@ssw0rd"
>
<Output TaskParameter="Exists" PropertyName="Exists" />
</FtpDirectoryExists>
<Message Text="Directory '1\2\3' exists: $(Exists)"/>
If the directory exists on the server you should see the following output in the console: Directory '1\2\3' exists: true
Exception returned by FTP server.
The developer of this task did not add an example in the summary documentation.
Represents an remote file or directory on a FTP server.
The developer of this task did not add an example in the summary documentation.
Represenatation of a FTP reply message.
The developer of this task did not add an example in the summary documentation.
Uploads a full directory content to a remote directory.
Uploads directory content, including all subdirectories and subdirectory content:
<Target Name="DeployWebsite">
<FtpUploadDirectoryContent
ServerHost="ftp.myserver.com"
Port="42"
Username="user"
Password="p@ssw0rd"
LocalDirectory="c:\build\mywebsite"
RemoteDirectory="root\www\mywebsite"
Recursive="true"
/>
To go a little step further. If the local directory looked like this:
[mywebsite]
[images]
1.gif
2.gif
3.gif
[js]
clientscript.js
nofocus.js
[css]
print.css
main.css
index.htm
contact.htm
downloads.htm
All directories and there content will be uploaded and a excact copy of the content of mywebsite directory will be created remotely.
If is set the false; only index.htm, contact.htm and downloads.htm will be uploaded and no subdirectories will be created remotely.
The status of an uninstall.
The developer of this task did not add an example in the summary documentation.
A class wrapping fusion api calls
The developer of this task did not add an example in the summary documentation.
A task for git to get the current commit datetime.
The developer of this task did not add an example in the summary documentation.
A task for Git commands.
The developer of this task did not add an example in the summary documentation.
A task for git to get the most current tag, commit count since tag, and commit hash.
The developer of this task did not add an example in the summary documentation.
A task to get the name of the branch or tag of git repository
The developer of this task did not add an example in the summary documentation.
A task for git to retrieve the number of commits on a revision.
The developer of this task did not add an example in the summary documentation.
A task for git to detect if there are pending changes
The developer of this task did not add an example in the summary documentation.
A task for git to get the current commit hash.
The developer of this task did not add an example in the summary documentation.
Html Help 1x compiler task.
The developer of this task did not add an example in the summary documentation.
A Html Help 2.0 compiler task.
The developer of this task did not add an example in the summary documentation.
MSBuild task to create installer with InnoSetup
Create installer
<InnoSetup
ScriptFile="setup.iss"
OutputFileName="MySetup.exe"
OutputPath="C:\SetupDir"
Quiet="True" />
MSBuild task to minimize the size of a css file.
The developer of this task did not add an example in the summary documentation.
Work in progress ...
The developer of this task did not add an example in the summary documentation.
Defines the modes for merging files.
The developer of this task did not add an example in the summary documentation.
Merge files into the destination file.
Merge CSS files together for better browser performance.
<Merge Mode="TextLine"
SourceFiles="Main.css;Login.css"
DestinationFile="All.css" />
Makes an HTTP request, optionally validating the result and writing it to a file.
Example of a update request ensuring "Database upgrade check completed successfully." was returned.
<HttpRequest Url="http://mydomain.com/index.php?checkdb=1"
EnsureResponseContains="Database upgrade check completed successfully."
FailOnNon2xxResponse="true" />
A base class for NuGet tasks.
The developer of this task did not add an example in the summary documentation.
Deletes a package with a specific version. It can be useful if the server has disallow to overwrite existing packages.
The developer of this task did not add an example in the summary documentation.
Installs a package using the specified sources.
The developer of this task did not add an example in the summary documentation.
Creates a NuGet package based on the specified nuspec or project file.
The developer of this task did not add an example in the summary documentation.
Pushes a package to the server and optionally publishes it.
The developer of this task did not add an example in the summary documentation.
Downloads and unzips (restores) any packages missing from the packages folder.
The developer of this task did not add an example in the summary documentation.
Updates packages
The developer of this task did not add an example in the summary documentation.
Compiles regular expressions and saves them to disk in an assembly.
Creates an assembly with the compiled regular expressions.
\G[^<]+ RegexOptions.Singleline | RegexOptions.Multiline \G<%--(([^-]*)-)*?-%> RegexOptions.Singleline | RegexOptions.Multiline \G<%(?![@%])(?<code>.*?)%> RegexOptions.Singleline | RegexOptions.Multiline MSBuild.Community.RegularExpressionsBuildAssembler task for Sandcastle.
The developer of this task did not add an example in the summary documentation.
A base class for Sandcastle Tools,
The developer of this task did not add an example in the summary documentation.
ChmBuilder task for Sandcastle.
The developer of this task did not add an example in the summary documentation.
DBCSFix task for Sandcastle.
The developer of this task did not add an example in the summary documentation.
MRefBuilder task for Sandcastle.
The developer of this task did not add an example in the summary documentation.
The Sandcastle task.
Create the Html Help for MSBuild Community Task project.
<Sandcastle TopicStyle="vs2005"
WorkingDirectory="$(MSBuildProjectDirectory)\Help"
Assemblies="@(Assemblies)"
Comments="@(Comments)"
References="@(References)"
ChmName="MSBuildTasks"
HxName="MSBuildTasks" />
A class representing the sandcastle enviroment.
The developer of this task did not add an example in the summary documentation.
XslTransform task for Sandcastle.
The developer of this task did not add an example in the summary documentation.
The contract for a service that will provide access to the file system.
The developer of this task did not add an example in the summary documentation.
Provides access to the file system.
The developer of this task did not add an example in the summary documentation.
The list of the commands available to the GacUtil Task
The developer of this task did not add an example in the summary documentation.
MSBuild task to install and uninstall assemblies into the GAC
Install a dll into the GAC.
<GacUtil
Command="Install"
Assemblies="MSBuild.Community.Tasks.dll"
Force="true" />
Compresses JavaScript source by removing comments and unnecessary whitespace. It typically reduces the size of the script by half, resulting in faster downloads and code that is harder to read.
The developer of this task did not add an example in the summary documentation.
Defines a database host within the Oracle TNSNAMES.ORA file.
Add an entry to the system default TNSNAMES.ORA file and update any entry that already exists:
Contains information about a TNS definition
The developer of this task did not add an example in the summary documentation.
Locates host entries within a TNSNAMES.ORA file
The developer of this task did not add an example in the summary documentation.
Task wrapping the Window Resource Kit Robocopy.exe command.
Deploy website to web server.
<RoboCopy
SourceFolder="$(MSBuildProjectDirectory)"
DestinationFolder="\\server\webroot\"
Mirror="true"
ExcludeFolders=".svn;obj;Test"
ExcludeFiles="*.cs;*.resx;*.csproj;*.webinfo;*.log"
NoJobHeader="true"
/>
A task to play a sound from a .wav file path or URL.
To play the windows XP startup sound, use
<Sound SystemSoundFile="..\Media\Windows XP Startup.wav" />
A base class that has a file.
The developer of this task did not add an example in the summary documentation.
Commands for the tasks.
The developer of this task did not add an example in the summary documentation.
A task for the pdbstr from source server.
The developer of this task did not add an example in the summary documentation.
A class representing a source file.
The developer of this task did not add an example in the summary documentation.
A base class for source indexing a pdb symbol file.
The developer of this task did not add an example in the summary documentation.
A task for the srctool from source server.
The developer of this task did not add an example in the summary documentation.
A subversion source index task.
The developer of this task did not add an example in the summary documentation.
A class representing a symbol file.
The developer of this task did not add an example in the summary documentation.
Task to index pdb files and entries to retrieve source files from Team Foundation Server source control.
Index a PDB.
<TfsSourceIndex SymbolFiles="@(Symbols)" TeamProjectCollectionUri="http://my-tfsserver/tfs/DefaultCollection" />
The SqlPubWiz commands
The developer of this task did not add an example in the summary documentation.
The Database Publishing Wizard enables the deployment of SQL Server databases (both schema and data) into a shared hosting environment.
Generate the database script for Northwind on localhost.
<SqlPubWiz
Database="Northwind"
Output="Northwind.sql"
SchemaOnly="true" />
Copy a file or folder in Subversion
Create a tag of the trunk with the current Cruise Control build number:
<Target Name="TagTheBuild">
<SvnCopy SourcePath="file:///d:/svn/repo/Test/trunk"
DestinationPath="file:///d:/svn/repo/Test/tags/BUILD-$(CCNetLabel)"
Message="Automatic build of $(CCNetProject)" />
</Target>
Subversion client base class
The developer of this task did not add an example in the summary documentation.
The developer of this task did not add an example in the summary documentation.
The developer of this task did not add an example in the summary documentation.
The developer of this task did not add an example in the summary documentation.
The developer of this task did not add an example in the summary documentation.
The developer of this task did not add an example in the summary documentation.
The developer of this task did not add an example in the summary documentation.
Subversion status command.
The developer of this task did not add an example in the summary documentation.
Commands for the SymStore tasks.
The developer of this task did not add an example in the summary documentation.
Task that wraps the Symbol Server SymStore.exe application.
The developer of this task did not add an example in the summary documentation.
Represents the response from a tf.exe info command
The developer of this task did not add an example in the summary documentation.
Represents the server information section created by a tf.exe info command
The developer of this task did not add an example in the summary documentation.
Represents the local information section from a tf.exe info command
The developer of this task did not add an example in the summary documentation.
A task for Team Foundation Server version control.
The developer of this task did not add an example in the summary documentation.
The contract for a service that will provide access to the registry.
The developer of this task did not add an example in the summary documentation.
Provides access to the Windows registry.
The developer of this task did not add an example in the summary documentation.
Provides information about the build user.
Get build user information.
<User>
<Output TaskParameter="UserNameWithDomain" PropertyName="BuildUserID" />
<Output TaskParameter="FullName" PropertyName="BuildUserName" />
<Output TaskParameter="Email" PropertyName="BuildUserEmail" />
<Output TaskParameter="Phone" PropertyName="BuildUserPhone" />
</User>
Upload a local file to a remote URI.
Upload the xml file.
<WebUpload RemoteUri="http://intranet/upload" FileName="page.xml" />
Performs multiple updates on an XML file
These examples will demonstrate how to make multiple updates to a XML file named web.config. It looks like:
<?xml version="1.0" encoding="utf-8" ?>
Sets an application mapping for a filename extension on an existing web directory.
Map the .axd extension to the lastest version of ASP.NET:
<WebDirectoryScriptMap VirtualDirectoryName="MyWeb" Extension=".axd" MapToAspNet="True" VerifyFileExists="False" />
Base task for any IIS-related task.
The developer of this task did not add an example in the summary documentation.
Defines the possible IIS versions supported by the task.
The developer of this task did not add an example in the summary documentation.
Defines the possible application pool actions to be performed.
The developer of this task did not add an example in the summary documentation.
Defines the current application pool state.
The developer of this task did not add an example in the summary documentation.
Reads and modifies a web directory configuration setting.
Display the file system path of the MyWeb web directory:
<WebDirectorySetting VirtualDirectoryName="MyWeb" SettingName="Path">
<Output TaskParameter="SettingValue" PropertyName="LocalPath" />
</WebDirectorySetting>
<Message Text="MyWeb is located at $(LocalPath)" />
A wrapper for the ILMerge tool.
This example merges two assemblies A.dll and B.dll into one:
<PropertyGroup>
<outputFile>$(testDir)\ilmergetest.dll</outputFile>
<keyFile>$(testDir)\keypair.snk</keyFile>
<excludeFile>$(testDir)\ExcludeTypes.txt</excludeFile>
<logFile>$(testDir)\ilmergetest.log</logFile>
</PropertyGroup>
<ItemGroup>
<inputAssemblies Include="$(testDir)\A.dll" />
<inputAssemblies Include="$(testDir)\B.dll" />
<allowDuplicates Include="ClassAB" />
</ItemGroup>
<Target Name="merge" >
<ILMerge InputAssemblies="@(inputAssemblies)"
AllowDuplicateTypes="@(allowDuplicates)"
ExcludeFile="$(excludeFile)"
OutputFile="$(outputFile)" LogFile="$(logFile)"
DebugInfo="true" XmlDocumentation="true"
KeyFile="$(keyFile)" DelaySign="true" />
</Target>
Installs assemblies.
Install multiple assemblies by specifying the file names:
Uninstalls assemblies.
Uninstall multiple assemblies by specifying the file names:
<UninstallAssembly AssemblyFiles="Engine.dll;Presenter.dll" />
Performs the modulo operation on numbers.
Numbers evenly divide:
<Math.Modulo Numbers="12;4"> </Math.Modulo> Above example will display: 12 modulo 4 = 0
Math task base class
The developer of this task did not add an example in the summary documentation.
Displays a message on the console and waits for user input.
Pause the build if the interactive property is set:
<!-- Pause when invoked with the interactive property: msbuild myproject.proj /property:interactive=true -->
<Prompt Text="You can now attach the debugger to the msbuild.exe process..." Condition="'$(Interactive)' == 'True'" />
Base class for Regex tasks Handles public properties for Input, Expression, Options and Output
The developer of this task did not add an example in the summary documentation.
Task to filter an Input list with a Regex expression. Output list contains items from Input list that matched given expression
Matches from TestGroup those names ending in a, b or c
<ItemGroup>
<TestGroup Include="foo.my.foo.foo.test.o" />
<TestGroup Include="foo.my.faa.foo.test.a" />
<TestGroup Include="foo.my.fbb.foo.test.b" />
<TestGroup Include="foo.my.fcc.foo.test.c" />
<TestGroup Include="foo.my.fdd.foo.test.d" />
<TestGroup Include="foo.my.fee.foo.test.e" />
<TestGroup Include="foo.my.fff.foo.test.f" />
</ItemGroup>
<Target Name="Test">
<!-- Outputs only items that end with a, b or c -->
<RegexMatch Input="@(TestGroup)" Expression="[a-c]$">
<Output ItemName ="MatchReturn" TaskParameter="Output" />
</RegexMatch>
<Message Text="
Output Match:
@(MatchReturn, '
')" />
</Target>
Task to replace portions of strings within the Input list Output list contains all the elements of the Input list after performing the Regex Replace.
1st example replaces first occurance of "foo." with empty string 2nd example replaces occurance of "foo." after character 6 with "oop." string
<ItemGroup>
<TestGroup Include="foo.my.foo.foo.test.o" />
<TestGroup Include="foo.my.faa.foo.test.a" />
<TestGroup Include="foo.my.fbb.foo.test.b" />
<TestGroup Include="foo.my.fcc.foo.test.c" />
<TestGroup Include="foo.my.fdd.foo.test.d" />
<TestGroup Include="foo.my.fee.foo.test.e" />
<TestGroup Include="foo.my.fff.foo.test.f" />
</ItemGroup>
<Target Name="Test">
<Message Text="Input:
@(TestGroup, '
')"/>
<!-- Replaces first occurance of "foo." with empty string-->
<RegexReplace Input="@(TestGroup)" Expression="foo\." Replacement="" Count="1">
<Output ItemName ="ReplaceReturn1" TaskParameter="Output" />
</RegexReplace>
<Message Text="
Output Replace 1:
@(ReplaceReturn1, '
')" />
<!-- Replaces occurance of "foo." after character 6 with "oop." string-->
<RegexReplace Input="@(TestGroup)" Expression="foo\." Replacement="oop" Startat="6">
<Output ItemName ="ReplaceReturn2" TaskParameter="Output" />
</RegexReplace>
<Message Text="
Output Replace 2:
@(ReplaceReturn2, '
')" />
</Target>
Different ways to specify the assembly in a UsingTask element.
The developer of this task did not add an example in the summary documentation.
A Task that generates a XSD schema of the tasks in an assembly.
Creates schema for MSBuild Community Task project
<TaskSchema Assemblies="Build\MSBuild.Community.Tasks.dll"
OutputPath="Build"
CreateTaskList="true"
IgnoreMsBuildSchema="true"
Includes="Microsoft.Build.Commontypes.xsd"/>
Retrieves the list of Projects contained within a Visual Studio Solution (.sln) file
Returns project name, GUID, and path information from test solution
<Target Name="Test">
<GetSolutionProjects Solution="TestSolution.sln">
<Output ItemName="ProjectFiles" TaskParameter="Output"/>
</GetSolutionProjects>
<Message Text="Project names:" />
<Message Text="%(ProjectFiles.ProjectName)" />
<Message Text="Relative project paths:" />
<Message Text="%(ProjectFiles.ProjectPath)" />
<Message Text="Project GUIDs:" />
<Message Text="%(ProjectFiles.ProjectGUID)" />
<Message Text="Full paths to project files:" />
<Message Text="%(ProjectFiles.FullPath)" />
</Target>
MSBuild task to execute DDL and SQL statements.
<PropertyGroup>
<ConnectionString>Server=localhost;Integrated Security=True</ConnectionString>
</PropertyGroup>
<Target Name="ExecuteDDL">
<ExecuteDDL ConnectionString="$(ConnectionString)" Files="SqlBatchScript.sql" ContinueOnError="false" />
</Target>
The kind of Subversion node. The names match the text output by "svn info".
The developer of this task did not add an example in the summary documentation.
The Subversion schedule type.
The developer of this task did not add an example in the summary documentation.
Run the "svn info" command and parse the output
This example will determine the Subversion repository root for a working directory and print it out.
<Target Name="printinfo">
<SvnInfo LocalPath="c:\code\myapp">
<Output TaskParameter="RepositoryRoot" PropertyName="root" />
</SvnInfo>
<Message Text="root: $(root)" />
</Target>
MSBuild task that replaces tokens in a template file and writes out a new file.
<ItemGroup>
<Tokens Include="Name">
<ReplacementValue>MSBuild Community Tasks</ReplacementValue>
</Tokens>
</ItemGroup>
<TemplateFile Template="ATemplateFile.template" TemplateEncoding="Windows-1251" OutputFilename="ReplacedFile.txt" OutputEncoding="UTF-16" Tokens="@(Tokens)" />
Gets the current date and time.
Using the Time task to get the Month, Day, Year, Hour, Minute, and Second:
<Time>
<Output TaskParameter="Month" PropertyName="Month" />
<Output TaskParameter="Day" PropertyName="Day" />
<Output TaskParameter="Year" PropertyName="Year" />
<Output TaskParameter="Hour" PropertyName="Hour" />
<Output TaskParameter="Minute" PropertyName="Minute" />
<Output TaskParameter="Second" PropertyName="Second" />
</Time>
<Message Text="Current Date and Time: $(Month)/$(Day)/$(Year) $(Hour):$(Minute):$(Second)" />
Set property "BuildDate" to the current date and time:
<Time Format="yyyyMMddHHmmss">
<Output TaskParameter="FormattedTime" PropertyName="buildDate" />
</Time>
Represents a single XmlNode selected using an XML task.
The developer of this task did not add an example in the summary documentation.
Reads a value or values from lines of XML
Read an attribute value by selecting it with an XPath expression:
Provides methods used by all of the XML tasks
The developer of this task did not add an example in the summary documentation.
A task to merge and transform a set of xml files.
This example for generating a report from a set of NUnit xml results:
$(project) $(configuration) $(MSBuildProjectFullPath) $(MSBuildBinPath) $(MSBuildCommunityTasksPath)\$(nunitReportXsl) This examples shows all available task attributes:Replace text in file(s) using a Regular Expression.
Search for a version number and update the revision.
<FileUpdate Files="version.txt"
Regex="(\d+)\.(\d+)\.(\d+)\.(\d+)"
ReplacementText="$1.$2.$3.123" />
Uses FxCop to analyse managed code assemblies and reports on their design best-practice compliance.
Shows how to analyse an assembly and use an XSLT stylesheet to present the report as an HTML file. If the static anlysis fails, the build does not stop - this is controlled with the FailOnError parameter.
<FxCop
TargetAssemblies="$(MSBuildCommunityTasksPath)\MSBuild.Community.Tasks.dll"
RuleLibraries="@(FxCopRuleAssemblies)"
Rules="Microsoft.Design#CA1012;-Microsoft.Performance#CA1805"
AnalysisReportFileName="Test.html"
DependencyDirectories="$(MSBuildCommunityTasksPath)"
FailOnError="False"
ApplyOutXsl="True"
OutputXslFileName="C:\Program Files\Microsoft FxCop 1.32\Xml\FxCopReport.xsl"
/>
Defines the actions that can be performed on a service.
The developer of this task did not add an example in the summary documentation.
Task that can control a Windows service.
Restart Web Server
<ServiceController ServiceName="w3svc" Action="Restart" />
Task that can determine the status of a specified service on a target server.
Check status of SQL Server
<ServiceQuery ServiceName="MSSQLServer">
<Output TaskParameter="Status" PropertyName="ResultStatus" />
</ServiceQuery>
<Message Text="MSSQLServer Service Status: $(ResultStatus)"/>
Creates a new application pool on a local or remote machine with IIS installed. The default is to create the new application pool on the local machine. If connecting to a remote machine, you can specify the and for the task to run under.
Create a new application pool on the local machine.
<AppPoolCreate AppPoolName="MyAppPool" />
Creates a new web directory on a local or remote machine with IIS installed. The default is to create the new web directory on the local machine. The physical path is required to already exist on the target machine. If connecting to a remote machine, you can specify the and for the task to run under.
Create a new web directory on the local machine.
<WebDirectoryCreate VirtualDirectoryName="MyVirDir"
VirtualDirectoryPhysicalPath="C:\Inetpub\MyWebDir" />
Deletes an existing application pool on a local or remote machine with IIS installed. The default is to delete an existing application pool on the local machine. If connecting to a remote machine, you can specify the and for the task to run under.
Delete an existing application pool on the local machine.
<AppPoolDelete AppPoolName="MyAppPool" />
Deletes a web directory on a local or remote machine with IIS installed. The default is to delete the web directory on the local machine. If connecting to a remote machine, you can specify the and for the task to run under.
Deletes a web directory on the local machine.
<WebDirectoryDelete VirtualDirectoryName="MyVirDir" />
Actions the can do.
The developer of this task did not add an example in the summary documentation.
Allows control for an application pool on a local or remote machine with IIS installed. The default is to control the application pool on the local machine. If connecting to a remote machine, you can specify the and for the task to run under.
Restart an application pool on the local machine.
<AppPoolController AppPoolName="MyAppPool" Action="Restart" />
Sends an email message
Example of sending an email.
<Target Name="Mail">
<Mail SmtpServer="localhost"
To="[email protected]"
From="[email protected]"
Subject="Test Mail Task"
Body="This is a test of the mail task." />
</Target>
Add numbers
Adding numbers:
<Math.Add Numbers="4;3">
<Output TaskParameter="Result" PropertyName="Result" />
</Math.Add>
<Message Text="Add 4+3= $(Result)"/>
Divide numbers
<Math.Divide Numbers="1;2"> </Math.Divide> Above example will display: Divide 1/2= 0.5
Multiple numbers
<Math.Multiple Numbers="10;3">
<Output TaskParameter="Result" PropertyName="Result" />
</Math.Multiple>
<Message Text="Multiple 10*3= $(Result)"/>
Subtract numbers
<Math.Subtract Numbers="10;3">
<Output TaskParameter="Result" PropertyName="Result" />
</Math.Subtract>
<Message Text="Subtract 10-3= $(Result)"/>
Moves files on the filesystem to a new location.
Move a file to another folder
<MV SourceFiles="Test\MoveMe.txt"
DestinationFolder="Test\Move" />
Rename a file
<MV SourceFiles="Test\Move\MoveMe.txt"
DestinationFiles="Test\Move\Renamed.txt" />
Runs the NDoc application.
Generated html help file.
<NDoc Documenter="MSDN"
ProjectFilePath="MSBuild.Community.Tasks.ndoc" />
Run NUnit 2.4 on a group of assemblies.
Run NUnit tests.
<ItemGroup>
<TestAssembly Include="C:\Program Files\NUnit 2.4\bin\*.tests.dll" />
</ItemGroup>
<Target Name="NUnit">
<NUnit Assemblies="@(TestAssembly)" />
</Target>
Run NUnit 3.x on a group of assemblies.
Run NUnit3 tests.
<CreateItem Include="*\bin\Debug\*.*.UnitTests.dll">
<Output TaskParameter="Include" ItemName="TestAssemblies"/>
</CreateItem>
<Target Name="NUnit3">
<!-- Run NUnit passing in the list of assemblies built above -->
<NUnit3 Assemblies="@(TestAssemblies)"
Process="Multiple"
TestTimeout="2000"
Framework="v4.0"
Force32Bit="true"
Workers="10"
EnableShadowCopy="true"
OutputXmlFile="myTestOutput.xml"
WorkingDirectory="./"
ShowLabels="All"
NoHeader="true"
NoColor="true"
Verbose="true"/>
</Target>
一个强类型的资源类,用于查找本地化的字符串等。
The developer of this task did not add an example in the summary documentation.
Reads a value from the Registry
Read .NET Framework install root from Registry.
<RegistryRead
KeyName="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework"
ValueName="InstallRoot">
<Output TaskParameter="Value" PropertyName="InstallRoot" />
</RegistryRead>
<Message Text="InstallRoot: $(InstallRoot)"/>
Writes a value to the Registry
Write a value to Registry
<RegistryWrite
KeyName="HKEY_CURRENT_USER\SOFTWARE\MSBuildTasks"
ValueName="RegistryWrite"
Value="Test Write" />
Executes code contained within the task.
Simple script that writes to the console
<Script Language="C#" Code="$(HelloCode)" Imports="System" />A task for sleeping for a specified period of time.
Causes the build to sleep for 300 milliseconds.
<Sleep Milliseconds="300" />
Executes a SQL command.
Example of returning a count of items in a table. Uses the default SelectMode of NonQuery.
<SqlExecute ConnectionString="server=MyServer;Database=MyDatabase;Trusted_Connection=yes;"
Command="create database MyDatabase" />
Example of returning the items of a table in an xml format.
<SqlExecute ConnectionString="server=MyServer;Database=MyDatabase;Trusted_Connection=yes;"
Command="select * from SomeTable for xml auto"
SelectMode="ScalarXml"
OutputFile="SomeTable.xml" />
Checkout a local working copy of a Subversion repository.
Checkout a working copy
<Target Name="Checkout">
<RemoveDir Directories="$(MSBuildProjectDirectory)\Test\Checkout" />
<SvnCheckout RepositoryPath="file:///d:/svn/repo/Test/trunk"
LocalPath="$(MSBuildProjectDirectory)\Test\Checkout">
<Output TaskParameter="Revision" PropertyName="Revision" />
</SvnCheckout>
<Message Text="Revision: $(Revision)"/>
</Target>
Subversion Commit command
The developer of this task did not add an example in the summary documentation.
Export a folder from a Subversion repository
Export from repository
<Target Name="Export">
<MakeDir Directories="$(MSBuildProjectDirectory)\Test" />
<RemoveDir Directories="$(MSBuildProjectDirectory)\Test\Export" />
<SvnExport RepositoryPath="file:///d:/svn/repo/Test/trunk"
LocalPath="$(MSBuildProjectDirectory)\Test\Export">
<Output TaskParameter="Revision" PropertyName="Revision" />
</SvnExport>
<Message Text="Revision: $(Revision)"/>
</Target>
Summarize the local revision(s) of a working copy.
The following example gets the revision of the current folder.
<Target Name="Version">
<SvnVersion LocalPath=".">
<Output TaskParameter="Revision" PropertyName="Revision" />
</SvnVersion>
<Message Text="Revision: $(Revision)"/>
</Target>
Subversion Update command
The developer of this task did not add an example in the summary documentation.
Unzip a file to a target directory.
Unzip file tasks
<Unzip ZipFileName="MSBuild.Community.Tasks.zip"
TargetDirectory="Backup"/>
Generates version information based on various algorithms
Get version information from file and increment revision.
<Version VersionFile="number.txt" BuildType="Automatic" RevisionType="Increment">
<Output TaskParameter="Major" PropertyName="Major" />
<Output TaskParameter="Minor" PropertyName="Minor" />
<Output TaskParameter="Build" PropertyName="Build" />
<Output TaskParameter="Revision" PropertyName="Revision" />
</Version>
<Message Text="Version: $(Major).$(Minor).$(Build).$(Revision)"/>
Downloads a resource with the specified URI to a local file.
Download the Microsoft.com home page.
<WebDownload FileUri="http://www.microsoft.com/default.aspx"
FileName="microsoft.html" />
Reads a value from a XML document using a XPath.
Read all targest from a build project.
<XmlRead Prefix="n"
Namespace="http://schemas.microsoft.com/developer/msbuild/2003"
XPath="/n:Project/n:Target/@Name"
XmlFileName="Subversion.proj">
<Output TaskParameter="Value" PropertyName="BuildTargets" />
</XmlRead>
<Message Text="Build Targets: $(BuildTargets)"/>
Updates a XML document using a XPath.
Update a XML element.
<XmlUpdate Prefix="n"
Namespace="http://schemas.microsoft.com/developer/msbuild/2003"
XPath="/n:Project/n:PropertyGroup/n:TestUpdate"
XmlFileName="Subversion.proj"
Value="Test from $(MSBuildProjectFile)"/>
Create a zip file with the files specified.
Create a zip file
<ItemGroup>
<ZipFiles Include="**\*.*" Exclude="*.zip" />
</ItemGroup>
<Target Name="Zip">
<Zip Files="@(ZipFiles)"
ZipFileName="MSBuild.Community.Tasks.zip" />
</Target>
Create a zip file using a working directory.
<ItemGroup>
<RepoFiles Include="D:\svn\repo\**\*.*" />
</ItemGroup>
<Target Name="Zip">
<Zip Files="@(RepoFiles)"
WorkingDirectory="D:\svn\repo"
ZipFileName="D:\svn\repo.zip" />
</Target>