由于.NET Core .csproj是一个常规的XML,您可以使用PowerShell脚本来更新其中的版本信息。例如,您可能有以下MyProject\MyProject.csproj
:
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.0</TargetFramework>
<Version>1.2.3.4</Version>
</PropertyGroup>
<ItemGroup>
<Compile Include="**\*.cs" />
<EmbeddedResource Include="**\*.resx" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NETCore.App" Version="1.0.1" />
</ItemGroup>
</Project>
然后在AppVeyor脚本修补<Version>
是以下几点:
$xmlPath = "$env:appveyor_build_folder\MyProject\MyProject.csproj"
$xml = [xml](get-content $xmlPath)
$propertyGroup = $xml.Project.PropertyGroup | Where { $_.Version}
$propertyGroup.Version = $env:appveyor_build_version
$xml.Save($xmlPath)
谢谢,这费奥多帮助解决! – Valentine
这会在AppVeyor中实现吗? – Julian
是的,我们有一个问题:https://github.com/appveyor/ci/issues/1404 –