【发布时间】:2020-01-15 05:28:13
【问题描述】:
我正在编写一个 powershell 脚本来自动在 TeamCity 上构建 .NET 项目。第一步是安装 msbuild。以下是我目前得到的脚本:
# download msbuild
$Url = 'https://aka.ms/vs/15/release/vs_buildtools.exe'
$msBuildInstaller = ([System.Environment]::ExpandEnvironmentVariables("%TEMP%\vs_BuildTools.exe"))
Invoke-WebRequest -OutFile "$msBuildInstaller" $Url
# install msbuild
$installDir = "$Env:UserProfile\msbuild"
$installDirCache = "$Env:UserProfile\msbuild\cache"
$installDirShared = "$Env:UserProfile\msbuild\shared"
Start-Process -FilePath "$msBuildInstaller" -Verb RunAs -Wait -PassThru -ArgumentList "--add Microsoft.VisualStudio.Workload.MSBuildTools --add Microsoft.VisualStudio.Workload.NetCoreBuildTools --add Microsoft.VisualStudio.Workload.ManagedDesktopBuildTools --add Microsoft.VisualStudio.Workload.WebBuildTools --add Microsoft.Net.Component.4.7.1.SDK --add Microsoft.Net.Component.4.7.1.TargetingPack --norestart --quiet --force --path install=$installDir --path cache=$installDirCache --path shared=$installDirShared"
有了这个脚本,我可以在$installDir 安装 msbuild。但是当我在窗口资源管理器中删除$installDir 并再次运行脚本时,它不起作用。
我怎样才能让它工作?
【问题讨论】:
-
如果您有特殊原因手动删除要测试的文件夹,请告诉我,这是删除,而不是卸载:)
标签: c# visual-studio powershell msbuild