VS2017 安装一直失败并出现错误,因为无法安装 Microsoft.Net.4.5.2.TargetingPack

VS2017 installation keeps failing with error as couldn't install Microsoft.Net.4.5.2.TargetingPack

我尝试安装 VS2019 并重新安装了很多次,但每次安装都在中间停止并显示一条消息 Setup completed with warning .Net Framework 4.5.2 目标包未安装。

在日志中我可以看到

PackageId:Microsoft.Net.4.5.2.TargetingPack;PackageAction:Install;ReturnCode:1625;

在这个阶段我可以打开 VS 2017,但没有 Web 模板。

错误详情:

Package 'Microsoft.Net.4.5.2.TargetingPack,version=4.5.51651.1' failed to install.
Search URL
    https://aka.ms/VSSetupErrorReports?q=PackageId=Microsoft.Net.4.5.2.TargetingPack;PackageAction=Install;ReturnCode=1625
Details
    MSI: C:\ProgramData\Microsoft\VisualStudio\Packages\Microsoft.Net.4.5.2.TargetingPack,version=4.5.51651.1\netfx_452mtpack.msi, Properties:  REBOOT=ReallySuppress ARPSYSTEMCOMPONENT=1  MSIFASTINSTALL="7"  EXTUI="1" 
    Return code: 1625
    Return code details: This installation is forbidden by system policy. Contact your system administrator.
Log
    C:\Users\ihalarnkar162161\AppData\Local\Temp\dd_setup_20200417231054_219_Microsoft.Net.4.5.2.TargetingPack.log
Impacted workloads
    ASP.NET and web development (Microsoft.VisualStudio.Workload.NetWeb,version=15.8.27906.1)
Impacted components
    .NET Framework 4 – 4.6 development tools (Microsoft.Net.ComponentGroup.TargetingPacks.Common,version=15.6.27406.0)
    .NET Framework 4.5.2 targeting pack (Microsoft.Net.Component.4.5.2.TargetingPack,version=15.6.27406.0)
    ASP.NET and web development tools (Microsoft.VisualStudio.Component.Web,version=15.8.27825.0)
    ASP.NET and web development tools prerequisites (Microsoft.VisualStudio.ComponentGroup.Web,version=15.9.28219.51)
    Cloud tools for web development (Microsoft.VisualStudio.ComponentGroup.Web.CloudTools,version=15.8.27729.1)
    Data sources for SQL Server support (Microsoft.VisualStudio.Component.SQL.DataSources,version=15.0.26621.2)
    Microsoft Azure WebJobs Tools (Component.Microsoft.VisualStudio.Web.AzureFunctions,version=15.7.27617.1)
    Microsoft Azure WebJobs Tools (Microsoft.VisualStudio.ComponentGroup.AzureFunctions,version=15.7.27617.1)
    SQL Server Data Tools (Microsoft.VisualStudio.Component.SQL.SSDT,version=15.9.28107.0)
    Windows Communication Foundation (Microsoft.VisualStudio.Component.Wcf.Tooling,version=15.8.27924.0)

错误1625表示:

ERROR_INSTALL_PACKAGE_REJECTED 1625 This installation is forbidden by system policy. Contact your system administrator.

根据https://docs.microsoft.com/en-us/windows/win32/msi/error-codes

我有根据的猜测是 运行 具有管理员权限的 vsinstaller(运行 作为管理员),它应该可以解决问题。

让我知道是否解决了问题