【发布时间】:2021-03-28 05:07:59
【问题描述】:
我想在下面的 test.csproj 文件中更改 ProductVersion 标记的值。我只需要将 ProductVersion: 8A-0V-W3 第一次出现的值更改为 A0-B0-C0
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">iPhoneSimulator</Platform>
<ProductVersion>8A-0V-W3</ProductVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
<DebugSymbols>true</DebugSymbols>
<ProductVersion>PK-0X-SD</ProductVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
<DebugType>none</DebugType>
<ProductVersion>SD-AA-SW</ProductVersion>
</PropertyGroup>
我想出了下面的命令,但它会删除所有出现的标签。有没有办法只删除第一次出现,然后将更新的标签插入同一位置
get-content ./test.csproj | select-string -pattern 'ProductVersion' -notmatch | Out-File ./test1.csproj
【问题讨论】:
标签: powershell scripting