'Unable to find type System.Web.MimeMapping error - Powershell on Azure DevOps Pipeline
I'm trying to run a Powershell script as a part of my build pipeline on Azure DevOps, but I keep getting the following error:
Unable to find type [System.Web.MimeMapping].
At D:\a\1\s\upload.ps1:31 char:15
+ $sourceMime = [System.Web.MimeMapping]::GetMimeMapping($sourceItem.Fu …
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Web.MimeMapping:TypeName) [], ParentContainsErrorRecordException
FullyQualifiedErrorId : TypeNotFound
The related bit of code in my Powershell script that's throwing the error:
# Get the source file contents and details, encode in base64
$sourceItem = Get-Item $sourceFile
$sourceBase64 = [Convert]::ToBase64String([IO.File]::ReadAllBytes($sourceItem.FullName))
$sourceMime = [System.Web.MimeMapping]::GetMimeMapping($sourceItem.FullName)
Any Pipelines gurus out there that can help?
Note: I've already tried using Add-Type -AssemblyName System.Web to no avail. This seems to be something related to the hosted agent (windows-latest) since the script runs fine on my local machine.
Thanks in advance.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
