zoukankan      html  css  js  c++  java
  • Visual Studio 在编译主项目之前自动编译另一个独立项目

    示例脚本

    msbuild

    rem DataUpgrade专用脚本,请勿删除!
    echo off
    
    set "msbuildPath="
    set "msbuildPath14=%ProgramFiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe"
    set "msbuildPath15=%ProgramFiles(x86)%\MSBuild\15.0\Bin\MSBuild.exe"
    set "msbuildPathvs17=%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\msbuild.exe"
    set "msbuildPathvs19=%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\msbuild.exe"
    
    if exist "%msbuildPath14%"  set "msbuildPath=%msbuildPath14%"
    if exist "%msbuildPath15%"  set "msbuildPath=%msbuildPath15%"
    if exist "%msbuildPathvs17%"  set "msbuildPath=%msbuildPathvs17%"
    if exist "%msbuildPathvs19%"  set "msbuildPath=%msbuildPathvs19%"
    
    cd /d %~dp0
    set "nugetPath=Build\nuget.exe"
    
    echo "MS编译器路径:%msbuildPath%"
    
    ::判断msbuild
    if "%msbuildPath%" == "" goto nomsbuild
    
    
    echo 正在编译导数工具代码...
    
    echo "还原NuGet"
    %nugetPath%  restore  "$(SolutionDir)src/DataUpgrade.Notification/DataUpgrade.Notification.csproj"
    
    echo "编译"
    "%msbuildPath%"  "$(SolutionDir)src/DataUpgrade.Notification/DataUpgrade.Notification.csproj" /t:Rebuild /p:Configuration="Debug" /consoleloggerparameters:ErrorsOnly /nologo /m
    
    if errorlevel 1 goto fail
    
    echo 编译成功...
    
    goto exit
    
    :nomsbuild
    echo 没有找到MSBUILD
    pause
    
    :exit
    exit /b 0
    
    :fail
    echo 编译成失败..
    exit /b 1
    

    使用方式

    将上述脚本放到 properties->Build Events 里面即可(自行修改需要目标项目位置)。

  • 相关阅读:
    第3章 对象基础
    [置顶] CSDN博客客户端(非官方)
    javascript 修改对象
    Print2Flash出现"System Error. Code:1722. RPC服务器不可用."错误解决办法
    ConfigHelper 配置文件辅助类
    多个委托方法的顺序执行
    javascript Table
    字符串拼接方式(待商榷)
    CSDN博客客户端(非官方)
    javascript 对象继承
  • 原文地址:https://www.cnblogs.com/hippieZhou/p/15532328.html
Copyright © 2011-2022 走看看