microsoft / vssetup.powershell

PowerShell module to interact with Visual Studio Setup
MIT License
227 stars 40 forks source link

Add DSC support #42

Closed heaths closed 4 years ago

heaths commented 6 years ago

PowerShell modules can also deploy DSC types. Consider a DSC type to check if an instance matching the desired product and workloads is present, and to either update the existing product (if compatible, e.g. Enterprise requested and Enterprise present, so update it; otherwise, install it) or install a new one (i.e. while supported via command line, it's not supported in the user interface so probably not this option).

heaths commented 6 years ago

The link to the channel is always the latest: https://aka.ms/vs/15/release/channel, or replace "release" with "preview" for the preview channel. Do not use other links directly. If you want to maintain a fixed last, see our layout documentation under https://docs.microsoft.com/visualstudio/install.

richlm commented 6 years ago

Thanks for proposing this Heath, would be great to see a DSC configuration out-of-the-box in a future release (or maybe even just documented). Including a powershell script (for inspiration) for others wanting to do this in the meantime. Needs the VSSetup module.

` Import-Module "C:\temp\TFS Build\VSSetup"

$latestUrl = "https://aka.ms/vs/15/release/channel"

$latestUrl = "file:\\xxx\DSC_Resources2\VisualStudio\2017\catalog.json"

$currentVersionInfo = Get-VSSetupInstance $latestVersionInfo = Invoke-WebRequest -Uri "$latestUrl" | ConvertFrom-Json

Write-host $currentVersionInfo Write-Host $latestVersionInfo

[System.Version]$currentVersion = $currentVersionInfo.InstallationVersion Write-host $currentVersion

[System.Version]$latestVersion = new-object -TypeName "System.Version" -ArgumentList $latestVersionInfo.info.buildVersion Write-host $latestVersion

$compare = $currentVersion.CompareTo($latestVersion)

if ($compare -le 0) { $cmd = '\\xxx\DSC_Resources2\VisualStudio\2017\vs_enterprise__989764552.1525680344.exe' $args = @('update', '--addProductLang en-US', '--all', '--noWeb', '--norestart', '--quiet', '--wait', '--nocache') $output = & $cmd $args 2>&1 | Out-String Write-Host $output } `

heaths commented 6 years ago

If Visual Studio were already installed to provide the DSC type, why would you need the DSC? Obtaining it from the PSGallery as with other DSC providers would seem to provide the most flexibility. In-box providers are generally very generic. This would be for Visual Studio and related products like Build Tools only.

jwittner commented 4 years ago

I would love to see this. I recently ran into needing to update the versions of the Windows 10 SDK installed and found Visual Studio to be the easiest path to managing that. I'm thinking about writing up some DSC resources to contribute, but wanted to think through desired shape for them before doing so.

At minimum I'd like a resource that lets me define a class (community, pro, enterprise ) and version (2017, 2019) of visual studio and what components need to be present/absent.

Something like:

If it's important that people be able to remove components, I would split the above into two resources, one requiring an install (VSSetupInstance) and another defining required components (VSSetupInstanceComponents).

jwittner commented 4 years ago

Another thought I had was about updating Visual Studio - are most people automating this through Scheduled Tasks? Can VSSetup determine if an Update for VS is available? Would a param in the resource to define 'AutoUpdate' make sense?

heaths commented 4 years ago

Visual Studio detects updates and lets you decide when to install them. See https://docs.microsoft.com/en-us/visualstudio/install/update-visual-studio?view=vs-2019. In fact, more is being done in the enterprise space to update entire networks, and DSC is not part of that effort so I'm closing this issue as well. There's a lot of logic involved with determine when, from where, and how updates are applied that are being done in a uniform manner as part of that effort.

jwittner commented 4 years ago

@heaths - that method of detecting/installing updates doesn't work well for unattended machines, in my case the machines we use as build agents for Azure DevOps pipelines. I'm very interested in what "more is being done in the enterprise space to update entire networks" and if DSC is not a part of that effort, what's the mechanism being used?

heaths commented 4 years ago

More should be published soon. DSC just doesn't provide the flexibility admins want (when, from where, and what e.g. features) with the validation and control (e.g. fallback for third-party software) the setup team needs to retain to keep things successful.