This repository was archived by the owner on Mar 5, 2025. It is now read-only.
Description I would really love to see this command added. PS has been missing an easy way to modify files since v1. This comes in so handy for build systems. Our builds, first thing, edit a number of files to modify version numbers using this command e.g.:
# Update C# interop assembly version
Edit-FileContent -Path (Join-Path $rootPath 'src/Adapters/Acme.Wiley.Coyote.Api/Acme.Wiley.Coyote.Api.csproj') `
-Pattern '(?<=\<Version\>)(.*?)(?=\</Version\>)' `
-Replacement "${wileyVersion}.0"
Edit-FileContent -Path (Join-Path $rootPath 'src/Adapters/Acme.Wiley.Coyote.Api/Acme.Wiley.Coyote.Api.csproj') `
-Pattern '(?<=\<InformationalVersion\>)(.*?)(?=\</InformationalVersion\>)' `
-Replacement "${wileyVersion}${suffix}"
# WileyClient Conan C++ Support
Edit-FileContent -Path (Join-Path $rootPath 'src/WileyClient/conanfile.py') `
-Pattern '(?<= version\s*=\s*'')(.*?)(?='')' `
-Replacement "${wileyVersion}${suffix}"
# WileyManagement Conan C++ Support
Edit-FileContent -Path (Join-Path $rootPath 'src/WileyManagement/conanfile.py') `
-Pattern '(?<= version\s*=\s*'')(.*?)(?='')' `
-Replacement "${wileyVersion}${suffix}"
Edit-FileContent -Path (Join-Path $rootPath 'src/WileyManagement/conanfile.py') `
-Pattern '(?<=WileyClient/)(.*?)(?=@Acme)' `
-Replacement "${wileyVersion}${suffix}"
# NuGet C# Support
Edit-FileContent -Path (Join-Path $rootPath 'build/NuGet/WileyClientPkg/Acme.Wiley.Coyote.Api.nuspec') `
-Pattern '(?<=\<version\>)(.*?)(?=\</version\>)' `
-Replacement "${wileyVersion}${suffix}"
Edit-FileContent -Path (Join-Path $rootPath 'build/NuGet/WileyClientPkg/Acme.Wiley.Coyote.Api.nuspec') `
-Pattern '(?<=id="runtime\.native\.Acme\.Wiley\.Coyote\.Api"\s+version=")(.*?)(?=")' `
-Replacement "${wileyVersion}${suffix}"
Edit-FileContent -Path (Join-Path $rootPath 'build/NuGet/runtime.native.WileyClientPkg/runtime.native.Acme.Wiley.Coyote.Api.nuspec') `
-Pattern '(?<=\<version\>)(.*?)(?=\</version\>)' `
-Replacement "${wileyVersion}${suffix}"
# API Help Docs
$regexForHelpDocs = if ($Final) { '(?<== ")(\d)(.\d)*-?.* PRELIMINARY(?=")' } else { '(?<== ")(\d)(.\d)*-?.*(?= PRELIMINARY")' }
Edit-FileContent -Path (Join-Path $rootPath 'doc/CppReference/wiley-cpp-doxyfile') `
-Pattern $regexForHelpDocs `
-Replacement "${wileyVersion}${suffix}"
And here's the implementation - feel free to use as much (or little) as you want. https://github.com/Pscx/Pscx/blob/master/Src/Pscx/Commands/IO/EditFileCommand.cs
Reactions are currently unavailable