ErikEJ / EFCorePowerTools

Entity Framework Core Power Tools - reverse engineering, migrations and model visualization in Visual Studio & CLI
MIT License
2.05k stars 286 forks source link

efpt.postrun.cmd no longer defaults to project folder #2406

Closed rustygutter closed 2 weeks ago

rustygutter commented 2 weeks ago

For reasons I cannot determine, my "efpt.postrun.cmd" is no longer running correctly. Or to be more accurate, it runs, but the line that calls my powershell script now fails because the script is now run with a default folder of 'C:\WINDOWS\system32' rather than the project folder.

For many months, my "efpt.postrun.cmd" file contained the following line: pwsh -File .\TrackingManager\Db\_UpdateDbJsonTypes.ps1

the relative path was always found and my script ran without issue. But recently that stopped working. I was able to get things working only by updating the line to contain the full path: pwsh -File C:\Users\ted.barham\source\repos\TrackingManager\TrackingManager\Db\_UpdateDbJsonTypes.ps1

But this is not a solution as the full path is only valid on my machine, so it will never work on other developer machines.

Any idea why efpt.postrun.cmd is now defaulting to 'C:\WINDOWS\system32' rather than the project folder? Is there a 'switch' in efpt somewhere that I might have messed-up?

I have looked through the GIT history of my project files and I can't find anything that would seem to be responsible.

I am running VS 2022 Version 17.10.2. I have updated Visual Studio recently, and maybe that's the root of my problem? (but wouldn't other people have reported it?)

ErikEJ commented 2 weeks ago

I could be a VS change or some extension changing the working directory.

I think you can use something like this in your cmd file to make it more robust:

SET curDir=%~dp0
PUSHD %curDir%
rustygutter commented 2 weeks ago

Thanks for the suggestion to use %~dp0

It’s the perfect fix/work-around (disappointed I didn’t think of it). 😊

From: Erik Ejlskov Jensen @.> Sent: Tuesday, June 18, 2024 2:25 AM To: ErikEJ/EFCorePowerTools @.> Cc: rustygutter @.>; Author @.> Subject: Re: [ErikEJ/EFCorePowerTools] efpt.postrun.cmd no longer defaults to project folder (Issue #2406)

I could be a VS change or some extension changing the working directory.

I think you can use something like this in your cmd file to make it more robust:

SET curDir=%~dp0 PUSHD %curDir%

— Reply to this email directly, view it on GitHub https://github.com/ErikEJ/EFCorePowerTools/issues/2406#issuecomment-2175175451 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ACC3LRJAE24FALN4MX4QU6DZH7HCZAVCNFSM6AAAAABJOXDYEOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNZVGE3TKNBVGE . You are receiving this because you authored the thread. https://github.com/notifications/beacon/ACC3LRLGMCB3O5E2YXIOOODZH7HCZA5CNFSM6AAAAABJOXDYEOWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTUBU2FRW.gif Message ID: @. @.> >