
If you’ve ever authored SCOM management packs with Visual Studio Authoring Extensions then you’ve likely run into this issue. There’s no option that you can select to fix this. To my knowledge, the product group hasn’t fixed this yet. The solution is to add the following text to your .mpproj file, then reload your sloution:
<PropertyGroup Label="Globals">
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
</PropertyGroup>

Until they do, here’s an even better workaround; create your own external tool.


- Command: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
- Arguments: -NoProfile -ExecutionPolicy Bypass -File “C:\YOURPATH\Set-TargetFrameworkVersion.ps1” -SolutionDir $(SolutionDir)
- Initial Directory: $(SolutionDir
Set-TargetFrameworkVersion.ps1
<#
.SYNOPSIS
This PowerShell script is designed to add a TargetFrameworkVersion node to the Globals PropertyGroup of a Microsoft Project file (.mpproj) if it does not already exist.
If the PropertyGroup does not exist, it creates one and adds the TargetFrameworkVersion node with the value "v4.8".
.DESCRIPTION
This PowerShell script is designed to add a TargetFrameworkVersion node to the Globals PropertyGroup of a Microsoft Project file (.mpproj) if it does not already exist.
If the PropertyGroup does not exist, it creates one and adds the TargetFrameworkVersion node with the value "v4.8".
.PARAMETER SolutionDir
The path to the solution directory containing the Microsoft Project file (.mpproj). This parameter is mandatory and should be provided when running the script.
.EXAMPLE
.NOTES
Designed to be launched from Visual Studio MP Project as an External Tool, passing the $(SolutionDir) as the argument.
Set-TargetFrameworkVersion.ps1
#>
param (
[Parameter(Mandatory=$true)]
[string]$SolutionDir
)
$ScriptName = 'Set-TargetFrameworkVersion.ps1'
<# TESTING
$SolutionDir = "D:\SOURCE\Workspaces\WellsFargo\DataCollector"
#>
#region Functions
#####################################################
function LogIt($message,$Line) {
"$($Line): $message" | Add-content -Path $logfile -Force
}
Function _LINE_ {
$MyInvocation.ScriptLineNumber
}
####################################################
function Add-TargetFrameworkIfMissing {
param (
[Parameter(Mandatory = $true)]
[string]$ProjFile
)
[xml]$xml = Get-Content $ProjFile
$nsMgr = New-Object System.Xml.XmlNamespaceManager($xml.NameTable)
$ns = $xml.DocumentElement.NamespaceURI
$nsMgr.AddNamespace("msb", $ns)
# Look for the Globals PropertyGroup
$globalsGroup = $xml.SelectSingleNode("//msb:PropertyGroup[@Label='Globals']", $nsMgr)
if ($globalsGroup) {
# Check for existing TargetFrameworkVersion = v4.8
$tfv = $globalsGroup.SelectSingleNode("msb:TargetFrameworkVersion[text()='v4.8']", $nsMgr)
if (-not $tfv) {
$newNode = $xml.CreateElement("TargetFrameworkVersion", $ns)
$newNode.InnerText = "v4.8"
$globalsGroup.AppendChild($newNode) | Out-Null
$xml.Save($ProjFile)
Logit "TargetFrameworkVersion node added to existing Globals group in $ProjFile" $(_LINE_)
} else {
Logit "TargetFrameworkVersion already exists in Globals group. No changes made." $(_LINE_)
}
}
else {
# Create the entire PropertyGroup and add the node
$propertyGroup = $xml.CreateElement("PropertyGroup", $ns)
$propertyGroup.SetAttribute("Label", "Globals")
$tfvElement = $xml.CreateElement("TargetFrameworkVersion", $ns)
$tfvElement.InnerText = "v4.8"
$propertyGroup.AppendChild($tfvElement) | Out-Null
# Insert after the last PropertyGroup element
$propertyGroups = $xml.SelectNodes("//msb:PropertyGroup", $nsMgr)
if ($propertyGroups.Count -gt 0) {
$lastPG = $propertyGroups[$propertyGroups.Count - 1]
$lastPG.ParentNode.InsertAfter($propertyGroup, $lastPG) | Out-Null
} else {
# Fall back to appending to the root
$xml.Project.AppendChild($propertyGroup) | Out-Null
}
$xml.Save($ProjFile)
LogIt "Globals group with TargetFrameworkVersion added to $ProjFile" $($(_LINE_))
}
}
#####################################################
$ProjFile = (Get-ChildItem -Path $SolutionDir -Recurse -Filter *.mpproj | Where-Object { $_.Name -notmatch '\s' } | Select-Object -First 1).FullName
$logfile = Join-Path $($SolutionDir) "$($ScriptName)_log.txt"
$msg = @"
'Set-TargetFrameworkVersion.ps1': Log file created at: $(Get-Date -Format "yyyy-MM-dd HH:mm:ss")
`$SolutionDir: [$SolutionDir]"
"@
LogIt $msg $(_LINE_)
Set-Location $SolutionDir
Add-TargetFrameworkIfMissing -ProjFile $ProjFile
#Get-Content $logfile | Out-Default