aardio 文档

process.vswhere 库模块帮助文档

示例

常用参数示例:

参数支持用 -version <range 按版本范围筛选。支持语法如 -version [16.0,17.0)(表示大于等于 16.0 且小于 17.0,即 VS2019)。

导入 inet.installer 后可用以下 aardio 代码自动安装 Build 工具:

inet.installer("Visual Studio Build Tools","https://aka.ms/vs/stable/vs_BuildTools.exe","--nocache --add Microsoft.VisualStudio.Workload.ManagedDesktopBuildTools --add Microsoft.Net.Component.4.8.TargetingPack --add Microsoft.VisualStudio.Component.NuGet")

process 成员列表 #

process.vswhere() #

Visual Studio 安装实例定位工具。
参数可以是一个或多个字符串类型的命令行参数,
只有一个参数时可以包含空格,不会添加双引号或转义符,
如果有多个参数,则包含空格的参数按命令行参数规则添加双引号

process.vswhere 成员列表 #

Visual Studio 安装实例定位与 C++/MSBuild 编译工具。
官网示例
仅需要探查与自动安装 VC++ 运行时请使用库 sys.vc14

process.vswhere.build #

调用 MSBuild 编译项目并等待完成。
编译成功返回 true, 0;失败返回 false/null, 退出码或错误信息。
查找 Visual Studio 安装实例的版本参数由 process.vswhere.version 指定。

process.vswhere.build(projectPath,configuration,target,...) #

参数 @projectPath 指定工程或解决方案路径。

process.vswhere.buildReport(projectPath,configuration,target,...) #

调用 MSBuild 编译项目并解析输出,返回 {ok,exitCode,output,stdErr,errors,warnings}, 错误摘要, 退出码。

process.vswhere.dev(workDir,version,arch) #

打开 VS 开发人员命令行窗口进程,成功返回进程 ID 。

process.vswhere.exec(cmd,options) #

在缓存的 VS 开发人员命令行环境中同步执行命令(cl/link/nmake/midl/rc/msbuild 等)。
@options 可为工作目录字符串,或包含 workDir, arch(默认"x86"), version, env 的表。
返回结果表 {ok,exitCode,output,stdErr,errors,warnings}, 错误信息, 退出码

process.vswhere.findDevCmd(version) #

查找 vsdevcmd.bat(或 vcvarsall.bat)完整路径。
第二个返回值为 VS 安装根目录;失败返回 null, 错误信息

process.vswhere.findInstallPath(version,requires) #

查找 Visual Studio 或 Build Tools 安装根目录。
失败返回 null, 错误信息

process.vswhere.findMsBuild(version) #

查找 MSBuild.exe 完整路径。
第二个返回值为 VS 安装根目录;失败返回 null, 错误信息

process.vswhere.getDevEnv(arch,version,forceRefresh) #

获取并跨线程缓存 vsdevcmd.bat 初始化后的环境变量表。
@arch 默认为 "x86"(32 位 aardio 原生组件默认架构),也可指定 "amd64"/"x64"。
首次调用后自动缓存在进程共享区,后续调用无需重复运行 vsdevcmd.bat

process.vswhere.pbuild #

调用 MSBuild 编译项目。
启动成功返回进程管道( process.popen 对象),否则返回 null,错误信息。
查找 Visual Studio 安装实例的版本参数由 process.vswhere.version 指定。

process.vswhere.pbuild() #

返回对象:processPopenObject

process.vswhere.pbuild(projectPath,configuration,target,...) #

参数 @projectPath 指定工程或解决方案路径。

process.vswhere.pdev() #

返回对象:processPopenObject

process.vswhere.pdev(workDir,version,arch) #

打开交互式 VS 开发人员命令行管道进程(成功返回 process.popen 对象)。

process.vswhere.popen() #

返回对象:processPopenObject

process.vswhere.popen(cmd,options) #

在缓存的 VS 开发人员命令行环境中启动进程管道(process.popen 对象)。
@cmd 可为命令行字符串或参数数组(如 cl /nologo /LD test.cpp)。
@options 可为工作目录字符串,或包含 workDir, arch("x86"|"amd64"), version, env 的表

process.vswhere.version #

查询或执行命令时默认使用的版本参数。
默认值为 -latest,表示查找 VS2017 以及之后的最新版本。

Markdown 格式