XML MSBuild的自定义构建步骤

<Target Name="MyTarget">
  <BuildStep 
      Name="MyBuildStepName" 
      Message="My message for %(ConfigurationToBuild.FlavorToBuild)"
      TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
      BuildUri="$(BuildURI)"
      Condition="'$(IsDesktopBuild)'!='true'">
    <Output TaskParameter="Id" PropertyName="StepId" />
  </BuildStep>

  <!-- DO SOMETHING THAT CAN FAIL -->

  <BuildStep
      Id="$(StepId)"
      Name="MyBuildStepName"
      Status="Succeeded" 
      TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
      BuildUri="$(BuildURI)"
      Condition="'$(IsDesktopBuild)'!='true'" />
  <OnError ExecuteTargets="MyBuildStepError" />
</Target>

<Target Name="MyBuildStepError">
  <BuildStep
    Id="$(StepId)"
    Name="MyBuildStepName"
    Status="Failed"
    TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
    BuildUri="$(BuildURI)"
    Condition="'$(IsDesktopBuild)'!='true'" />
</Target>

XML MSBuild脚本中的Web.config转换

<!-- NOTE: You must set the build action to None (instead of Content) on the web.configs in your project
     to prevent the build from blowing up when it cannot copy the deleted original configs. -->

<PropertyGroup>
  <!-- Register the WebConfigTransformation target as a dependency of the get operation -->
  <GetDependsOn>
    $(GetDependsOn);
    WebConfigTransformation;
  </GetDependsOn>
</PropertyGroup>

<Target Name="WebConfigTransformation">
  <!-- Transform web.config files -->
  <BuildStep 
    Name="TransformConfigurationFiles" 
    Message="Transforming configuration files for: %(ConfigurationToBuild.FlavorToBuild)"
    TeamFoundationServerUrl="$(TeamFoundationServerUrl)" BuildUri="$(BuildURI)"
    Condition="'$(IsDesktopBuild)'!='true'">
    
    <Output TaskParameter="Id" PropertyName="StepId" />
  </BuildStep>

  <!-- Set all the files we will be using as writable. -->
  <ItemGroup>
    <_WebConfigFiles Include="$(SolutionRoot)\MyFirstProject\*.config">
      <Attributes>Normal</Attributes>
    </_WebConfigFiles>
    <_WebConfigFiles Include="$(SolutionRoot)\MySecondProject\*.config">
      <Attributes>Normal</Attributes>
    </_WebConfigFiles>
    <!-- etc for more config files in your solution -->
  </ItemGroup>
  <MSBuild.ExtensionPack.FileSystem.File
          TaskAction="SetAttributes"
          Files="@(_WebConfigFiles)" />

  <!-- Execute msbuild with the command line switches to transform the configuration files -->
  <Exec Command="$(FrameworkVersion40Dir)\msbuild.exe "$(SolutionRoot)\MyFirstProject\MyFirstProject.csproj" /T:TransformWebConfig /P:Configuration=%(ConfigurationToBuild.FlavorToBuild);RunCodeAnalysis=Never"/>
  <Exec Command="$(FrameworkVersion40Dir)\msbuild.exe "$(SolutionRoot)\MySecondProject\MySecondProject.csproj" /T:TransformWebConfig /P:Configuration=%(ConfigurationToBuild.FlavorToBuild);RunCodeAnalysis=Never"/>
  <!-- etc for more projects -->
  
  <!-- Delete the other original configs -->
  <Delete Files="@(_WebConfigFiles)" />
  
  <!-- Copy the transformed config to the root -->
  <Copy 
    SourceFiles="$(SolutionRoot)\MyFirstProject\obj\%(ConfigurationToBuild.FlavorToBuild)\TransformWebConfig\Transformed\Web.config" 
    DestinationFiles="$(SolutionRoot)\MyFirstProject\Web.config" />
  <Copy 
    SourceFiles="$(SolutionRoot)\MySecondProject\obj\%(ConfigurationToBuild.FlavorToBuild)\TransformWebConfig\Transformed\Web.config" 
    DestinationFiles="$(SolutionRoot)\MySecondProject\Web.config" />
  <!-- etc for more projects -->

  <BuildStep Id="$(StepId)" Name="TransformConfigurationFiles" Status="Succeeded"
    TeamFoundationServerUrl="$(TeamFoundationServerUrl)" BuildUri="$(BuildURI)"
    Condition="'$(IsDesktopBuild)'!='true'" />
  <OnError ExecuteTargets="WebConfigTransformationError"/>
</Target>
<Target Name="WebConfigTransformationError">
  <BuildStep Id="$(StepId)" Name="WebConfigTransformation" Status="Failed"
    TeamFoundationServerUrl="$(TeamFoundationServerUrl)" BuildUri="$(BuildURI)"
    Condition="'$(IsDesktopBuild)'!='true'" />
</Target>

XML Scratchlet

<?xmlversion="1.0"encoding="UTF-8"?>
<Module>
<ModulePrefstitle="Scratchlet"/>
  <UserPref name="url" display_name="Project URL" required="true" />
  <Content type="html">
    <![CDATA[
      <applet id='ProjectApplet' style='display:block' code='ScratchApplet' codebase='http://scratch.mit.edu/static/misc' archive='ScratchApplet.jar' height='387' width='482'><param name='project' value='__UP_url__'></applet>
    ]]>
  </Content>
</Module>

XML ASP.NET ProcessModel可以获得更好的吞吐量

<processModel 
   enable="true" 
   timeout="Infinite" 
   idleTimeout="Infinite" 
   shutdownTimeout="00:00:05" 
   requestLimit="Infinite" 
   requestQueueLimit="5000" 
   restartQueueLimit="10" 
   memoryLimit="60" 
   webGarden="false" 
   cpuMask="0xffffffff" 
   userName="machine" 
   password="AutoGenerate" 
   logLevel="Errors" 
   clientConnectedCheck="00:00:05" 
   comAuthenticationLevel="Connect" 
   comImpersonationLevel="Impersonate" 
   responseDeadlockInterval="00:03:00" 
   responseRestartDeadlockInterval="00:03:00" 
   autoConfig="false" 
   maxWorkerThreads="100" 
   maxIoThreads="100" 
   minWorkerThreads="40" 
   minIoThreads="30" 
   serverErrorMessageFile="" 
   pingFrequency="Infinite" 
   pingTimeout="Infinite" 
   maxAppDomains="2000" 
/>

XML system.net更改了更多并发的Web服务调用

<system.net>
  <connectionManagement>
    <add address="*" maxconnection="100" />
  </connectionManagement>
</system.net>

XML 防止视图在设备旋转时失效(=方向更改)

If you do not want views to reload on orientation changes simply override onConfigurationChanged in your Activity class:

@Override
public void onConfigurationChanged(Configuration newConfig){        
    super.onConfigurationChanged(newConfig);
}

And set the android:configChanges attribute in the manifest:

<activity android:name="..."
          android:label="@string/appName"
          android:configChanges="orientation"

XML Magento布局

<?xml version="1.0"?>
<!-- http://classyllama.com/development/magento-development/the-better-way-to-modify-magento-layout/ -->
<layout version="0.1.0">
 
<default>
 
	<reference name="head">
		<!-- Magento looks in /skin/frontend/<INTERFACE>/<THEME>/js/buyprinting.js
		for this file -->
		<action method="addItem"><type>skin_js</type><name>js/buyprinting.js</name></action>
 
		<!-- This removes the item that was set in the page.xml file -->
		<action method="removeItem"><type>skin_js</type><name>js/iehover-fix.js</name></action>
 
		<!-- Magento looks in /js/prototype/element.storage.js for this file -->
		<action method="addJs"><name>prototype/element.storage.js</name></action>
 
		<action method="addCss">
<stylesheet>css/buyprinting.css</stylesheet></action>
	</reference>
 
	<reference name="header">
        <!-- This adds a CMS block that can be called from the template file
        associated with the header block. -->
		<block type="cms/block" name="cms_quick_help">
			<action method="setBlockId"><block_id>quick_help</block_id></action>
		</block>
 
        <!-- The remove tag removes the blocks with the specified name from the layout -->
		<remove name="top.menu"/>
		<remove name="store_language"/>
		<remove name="breadcrumbs"/>
	</reference>
 
	<reference name="top.nav">
		<remove name="catalog.topnav"/>
	</reference>
 
	<reference name="left">
		<remove name="left.newsletter"/>
		<remove name="left.permanent.callout"/>
		<remove name="catalogsearch.leftnav"/>
 
        <!-- When you use the remove tag, it removes any blocks with the specified name from
            the entire layout, regardless of the context. So, if I remove right.newsletter in
            the <default> context and that name is used in say the <catalog_product_view> context,
            then both blocks will be removed.  Because remove operates on the global context,
            you can only remove an element once.  Since <remove name="right.newsletter" /> is
            being called in catalogsearch.xml, we have to unset it, or else we'll get an error.
 
            The line below only unsets the block from the parent's context, not the global
            layout context -->
		<action method="unsetChild"><name>right.newsletter</name></action>
	</reference>
 
	<reference name="right">
        <!-- Some blocks have to be removed using remove, others via unsetChild.
            I've not spent the time digging into the code to figure out why -->
		<remove name="right.permanent.callout"/>
		<remove name="catalog.compare.sidebar"/>
		<remove name="left.reports.product.viewed"/>
		<action method="unsetChild"><name>sale.reorder.sidebar</name></action>
		<action method="unsetChild"><name>wishlist_sidebar</name></action>
		<action method="unsetChild"><name>right.reports.product.viewed</name></action>
		<remove name="cart_sidebar"/>
	</reference>
 
</default>
 
<!-- CATALOG PAGES -->
	<catalog_product_view><!-- 2columns-right -->
		<reference name="root">
			<action method="setTemplate"><template>page/2columns-left.phtml</template></action>
		</reference>
		<reference name="content">
			<reference name="product.info">
				<block type="cms/block" name="cms_product_info_tabs">
					<action method="setBlockId"><block_id>product_info_tabs</block_id></action>
				</block>
				<block type="catalog/product_view" name="product.clone_prices" as="prices" template="catalog/product/view/price_clone.phtml"/>
				<action method="unsetChild"><name>tierprices</name></action>
				<action method="unsetChild"><name>addto</name></action>
				<remove name="addto"/>
				<reference name="product.info.options.wrapper.bottom">
					<action method="unsetChild"><name>product.tierprices</name></action>
				</reference>
			</reference>
		</reference>
	</catalog_product_view>
 
</layout>

XML SharePoint 2010自定义操作

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns=http://schemas.microsoft.com/sharepoint/">
    <CustomAction Id="GUID"
        Location="EditControlBlock"
        RegistrationId="1x0104"
        RegistrationType="ContentType"
        Title="Google this item"
        >
    <UrlAction Url="http://www.google.com/search?q={ItemId}" />
    </CustomAction>
</Elements>

XML Android:具有垂直居中的小部件的布局

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
	android:layout_width="match_parent" android:layout_height="match_parent"
	android:orientation="vertical">

		<ProgressBar 
		android:layout_centerInParent="true"
			style="@android:style/Widget.ProgressBar.Horizontal" 
			android:id="@+id/progressBar"
			android:layout_width="fill_parent" 
			android:layout_height="60sp"
			android:layout_margin="10sp"
			></ProgressBar>
		<TextView android:layout_below="@id/progressBar"
			android:text="XX% complete" android:gravity="center" android:id="@+id/status"
			android:layout_width="fill_parent" android:layout_height="wrap_content"></TextView>
	
</RelativeLayout>

XML Android:在两个活动之间淡出

Here's the code to do a nice smooth fade between two Activities.. 
 Create a file called fadein.xml in res/anim

<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
   android:interpolator="@android:anim/accelerate_interpolator"
   android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="2000" />


Create a file called fadeout.xml in res/anim

<?xml version="1.0" encoding="utf-8"?>

<alpha xmlns:android="http://schemas.android.com/apk/res/android"
   android:interpolator="@android:anim/accelerate_interpolator"
   android:fromAlpha="1.0" android:toAlpha="0.0" android:duration="2000" />


If you want to fade from Activity A to Activity B, put the following in the onCreate method for Activity B. Before setContentView works for me.



overridePendingTransition(R.anim.fadein, R.anim.fadeout);
If the fades are too slow for you, change android:duration in the xml files above to something smaller.