Repository navigation
Closed
Closed
Copy link
Labels
Area-FileSystem-Providerspecific to the FileSystem providerIssue-BugIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
My repro steps:
- Download the Enterprise WDK: https://docs.microsoft.com/en-us/windows-hardware/drivers/other-wdk-downloads
- Mount the ISO (Mount-DiskImage -ImagePath S:\iso\dev\EWDK_fe_release_20348_210507-1500.iso).
- From a "cmd.exe" prompt, run LaunchBuildEnv.cmd amd64
- Start Powershell 7.2 RC1: "c:\Program Files\PowerShell\7-preview\pwsh.exe"
- Run MSBuild.exe
But I do not think this is linked to the EWDK but the fact I'm running a exe from a mounted iso.
(was running just fine with 7.1.5 or the previous 7.2 preview)
Expected behavior
Successfully run msbuild.exeActual behavior
OperationStopped: Incorrect function. : 'E:\Program Files\Microsoft Visual Studio\2019\BuildTools\\MSBuild\Current\Bin\MSBuild.exe'Error details
Exception :
Type : System.IO.IOException
TargetSite :
Name : GetImmediateLinkTarget
DeclaringType : System.IO.FileSystem, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral,
PublicKeyToken=7cec85d7bea7798e
MemberType : Method
Module : System.Private.CoreLib.dll
Message : Incorrect function. : 'E:\Program Files\Microsoft Visual
Studio\2019\BuildTools\\MSBuild\Current\Bin\MSBuild.exe'
Data : System.Collections.ListDictionaryInternal
Source : System.Private.CoreLib
HResult : -2147024895
StackTrace :
at System.IO.FileSystem.GetImmediateLinkTarget(String linkPath, Boolean isDirectory, Boolean throwOnError, Boolean
returnFullPath)
at System.IO.FileSystem.ResolveLinkTarget(String linkPath, Boolean returnFinalTarget, Boolean isDirectory)
at System.IO.File.ResolveLinkTarget(String linkPath, Boolean returnFinalTarget)
at System.Management.Automation.NativeCommandProcessor.IsWindowsApplication(String fileName)
at System.Management.Automation.NativeCommandProcessor.InitNativeProcess()
at System.Management.Automation.NativeCommandProcessor.Prepare(IDictionary psDefaultParameterValues)
at System.Management.Automation.CommandProcessorBase.DoPrepare(IDictionary psDefaultParameterValues)
at System.Management.Automation.Internal.PipelineProcessor.Start(Boolean incomingStream)
at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput,
CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections,
FunctionContext funcContext)
at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
CategoryInfo : OperationStopped: (:) [], IOException
FullyQualifiedErrorId : System.IO.IOException
InvocationInfo :
ScriptLineNumber : 1
OffsetInLine : 1
HistoryId : -1
Line : msbuild.exe
PositionMessage : At line:1 char:1
+ msbuild.exe
+ ~~~~~~~~~~~
CommandOrigin : Internal
ScriptStackTrace : at <ScriptBlock>, <No file>: line 1Environment data
Name Value
---- -----
PSVersion 7.2.0-rc.1
PSEdition Core
GitCommitId 7.2.0-rc.1
OS Microsoft Windows 10.0.22000
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0Visuals
Metadata
Metadata
Assignees
Labels
Area-FileSystem-Providerspecific to the FileSystem providerIssue-BugIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.

Activity
[-]OperationStopped: Incorrect function when running an exe from a mounter ISO (i.e. Enterprise-WDK)[/-][+]OperationStopped: Incorrect function when running an exe from a mounted ISO[/+]iSazonov commentedon Oct 22, 2021
Jean Gautier (@jeanga)
Please open new issue in .Net Runtime repository and link that issue.Unbelievable, I just prepared a performance fix for this code which just gets rid of this
ResolveLinkTargetand fixes this problem in PowerShell :-)iSazonov commentedon Oct 23, 2021
After further study, I think this is purely a PowerShell problem, since it is correct that System.IO.File.ResolveLinkTarget() causes an IO exception for file systems (ISO, FAT, ...) that does not support reparse points.
jborean93 commentedon Oct 23, 2021
Heh I thought we fixed this as per #13605 but looks like it regressed again. Seems like #16295 (or some other PR) should include some tests for this specific scenario to stop it from happening once again.
iSazonov commentedon Oct 25, 2021
To add a test we need to create an ISO file with exe file on the fly.
jborean93 commentedon Oct 25, 2021
Not necessarily, you just need a file system that doesn't support reparse points. I see 2 easy-ish ways to do this
You can the use
Mount-DiskImageto mount either the ISO or VHDX for the test and try and run the executable placed in that volume.The VHDX scenario is simple to replicate
To avoid diskpart you could use PInvoke to call CreateVirtualDisk, creating the partition and formatting should also be doable using various PowerShell cmdlets as well if you wanted to avoid
diskpart.exealtogetherI have verified the VHDX example also excises this problematic code as the FAT format doesn't support reparse points.
iSazonov commentedon Oct 25, 2021
Jordan Borean (@jborean93) Thanks! I added the test.
jborean93 commentedon Oct 26, 2021
Thanks Ilya (@iSazonov) appreciate adding the test, should hopefully stop this from recurring in the future!
jeanga commentedon Nov 8, 2021
Verified fixed! Thanks!