msbuild

 msbuild是WINDOWS下构建平台。(linux : mono的xbuild ;dotnetcore build)   含有两部分内容  

  1.标准化的脚本描述语言

   2.msbuild命令

基础概念

   msbuild 脚本文件    它的架构描叙XSD文件在windows目录\Microsoft.NET\Framework64\v4.0.30319\MSBuild下

        对于2017之前项目脚本文件描叙基本类似:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{673D82EB-24D3-4018-9558-8602F06EAD77}</ProjectGuid>
    <OutputType>Exe</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>InjectOne</RootNamespace>
    <AssemblyName>InjectOne</AssemblyName>
    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.Core" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Data" />
    <Reference Include="System.Net.Http" />
    <Reference Include="System.Xml" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Program.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
  </ItemGroup>
  <ItemGroup>
    <None Include="App.config" />
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>

  

 Project 跟节点   xmlns属性是必须项。属性明细见: MSDN项目元素定义

     1.属性

          属性是PropertyGroup的字项,属性名称被限制为仅 ASCII 字符。 在项目中引用属性值,应将属性名称之间放置"$("和")"。MSDN保留属性

      2.项

           项是ItemGroup的子项,表示系统生成的输入文件。

      3.目标

          目标将任务以一定的顺序进行组织。

      4.任务

          任务是生成过程中执行的各项操作。系统内置了大量的task 同时github也有大量的task 见 扩展的msbuild任务

          自定义任务:自定义任务通过实现接口ITask 或者继承 Task 来实现。

            比如下面的简单例子:

public class MyTask : Task  
    {  
        public override bool Execute()  
        {  
            return true;  
        }  
    }  
View Code

       要想在项目构建过程中执行此任务,还需要配置执行目标。

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">  
    <Target Name="MyTarget">  
        <MyTask />  
    </Target>  
</Project>  

  通过自定定义任务就可以实现在构建期间,读取程序集的IL代码,并使用相关技术实现 CIL rewrite (比如 mono cecil,.NET Framework Profiling API,或者自行解析CIL生成的PE文件)。采用此种方法就可以进行静态织入代码实现诸如AOP之类的功能。

转载于:https://www.cnblogs.com/RunStone/p/7305005.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值