• csproj管理


    指定程序集版本

    // 1.0.0.0
    var version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
    

    指定文件(产品)版本

    string version = null;
    var attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyFileVersionAttribute), false);
    if (attributes == null ||attributes.Length == 0)
    {
        version = "";
    }
    else
    {
        version = ((AssemblyFileVersionAttribute)attributes[0]).Version;
    }
    

    MSBuild脚本重新生成项目

    @echo off
    chcp 65001
    
    :: MSBuild.exe 路径
    set MSBUILD_PATH=C:Program Files (x86)Microsoft Visual Studio2019EnterpriseMSBuildCurrentBinMSBuild.exe
    :: solution 路径
    set SOLUTION_FILE=%rootPath%****.csproj
    :: Release / Debug
    set BUILD_CONFIG=Release
    :: build / rebuild / clean
    set BUILD_TYPE=Rebuild
    :: AnyCPU / x64 / x86
    set BUILD_PLATFORM=AnyCPU
    :: OutputPath
    set OUTPUT_PATH=%rootPath%in
    
    @echo 编译开始
    rd "%OUTPUT_PATH%"\%BUILD_CONFIG% /s/q
    "%MSBUILD_PATH%" "%SOLUTION_FILE%" /t:%BUILD_TYPE% /p:Configuration=%BUILD_CONFIG%;Platform=%BUILD_PLATFORM%;OutDir="%OUTPUT_PATH%"\%BUILD_CONFIG% /m
    ::项目依赖项
    set rootPath2=F:Src
    "%MSBUILD_PATH%" "%rootPath2%依赖项目1.csproj" /t:%BUILD_TYPE% /p:Configuration=%BUILD_CONFIG%;Platform=%BUILD_PLATFORM%;OutDir="%OUTPUT_PATH%"\%BUILD_CONFIG%;WarningLevel=0 /clp:NoSummary;ShowTimestamp /verbosity:Quiet /m
    "%MSBUILD_PATH%" "%rootPath2%依赖项目2.csproj" /t:%BUILD_TYPE% /p:Configuration=%BUILD_CONFIG%;Platform=%BUILD_PLATFORM%;OutDir="%OUTPUT_PATH%"\%BUILD_CONFIG%;WarningLevel=0 /clp:NoSummary;ShowTimestamp /verbosity:Quiet /m
    @echo 编译结束
    
    pause
    

    整行替换

    指定字符串替换

    bandizip新建压缩包

    echo bandizip新建压缩包(覆盖已有文件)
    set RAR_PATH=C:Program FilesBandizipBandizip.exe
    ::项目名称 1.11.0.20031315 Release.zip
    set versionMain=1, 11, 0, 
    set hour=%time:~,2%
    if "%time:~,1%"==" " set hour=0%time:~1,1% 
    set anotherVariable=%date:~5,2%%date:~8,2%%date:~11,2%%hour%
    set RAR_NAME=项目名称 %versionMain%%anotherVariable% Release.zip
    set RAR_NAME2=%RAR_NAME:, =.%
    ::Release压缩到当前目录  Bandizip.exe c **.zip c:src
    "%RAR_PATH%" c "%OUTPUT_PATH%""%RAR_NAME2%" "%OUTPUT_PATH%"\%BUILD_CONFIG%
    
    echo 打开目录
    %SystemRoot%explorer.exe  "%OUTPUT_PATH%"
    pause
    
  • 相关阅读:
    正则表达式基础知识
    成功的基本法则
    Java实现简单的格式化信函生成器
    C实现哈希表
    C实现求解给定文本中以指定字符开头和结尾的子串数量的三种算法
    Java实现求解二项式系数及代码重构
    Java 异常处理学习总结
    C实现大整数幂求模问题的两种算法
    linux 学习前言
    提高编程能力的10种方法
  • 原文地址:https://www.cnblogs.com/wesson2019-blog/p/13955230.html
Copyright © 2020-2023  润新知