[build] fix local 'dotnet cake' builds (#2234)

I found `dotnet cake` fails with:

    C:\src\maui\src\Workload\Microsoft.Maui.Controls.Sdk\Microsoft.Maui.Controls.Sdk.csproj(53,5):
    error MSB4044: The "ReplaceText" task was not given a value for the required parameter "NewValue".

This is happening because `$(CI)` is not set, and
`$(PackageReferenceVersion)` is blank.

To solve this issue going forward:

* Make a `eng/Versions.dev.targets` as a local replacement for
  `eng/Versions.targets`.
* Create a `SetVersions` target so we don't need to declare the empty
  one anymore in several files.
* Set `$(PackageReferenceVersion)` and `$(VSComponentVersion)` to the
  default `$(PackageVersion)` value that comes from
  `Directory.Build.props`.

Now when I run `dotnet cake`, it is successful.
This commit is contained in:
Jonathan Peppers 2021-08-25 08:15:02 -05:00 коммит произвёл GitHub
Родитель d35cbdb03c
Коммит 6dc30378d7
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
6 изменённых файлов: 10 добавлений и 12 удалений

Просмотреть файл

@ -1,5 +1,6 @@
<Project>
<Import Condition="'$(SampleProject)' == 'true' or '$(CI)' != 'true' " Project="eng\Versions.dev.targets" />
<Import Condition="'$(SampleProject)' != 'true' and '$(CI)' == 'true'" Project="eng\Git.Build.targets" />
<Import Condition="'$(SampleProject)' != 'true' and '$(CI)' == 'true' " Project="eng\Versions.targets" />
<Import Project="eng\AndroidX.targets" />

9
eng/Versions.dev.targets Normal file
Просмотреть файл

@ -0,0 +1,9 @@
<!-- This file is an alternative to Versions.targets, when building locally and not for CI -->
<Project>
<Target Name="SetVersions">
<PropertyGroup>
<PackageReferenceVersion>$(PackageVersion)</PackageReferenceVersion>
<VSComponentVersion>$(PackageVersion)</VSComponentVersion>
</PropertyGroup>
</Target>
</Project>

Просмотреть файл

@ -91,9 +91,6 @@
</Target>
<!-- Eventually replaced by eng/Version.targets -->
<Target Name="SetVersions" />
<PropertyGroup>
<!-- These files should invalidate ./bin/dotnet completely -->
<_Inputs>

Просмотреть файл

@ -25,9 +25,6 @@
<BeforePack>_UpdateTemplateVersions</BeforePack>
</PropertyGroup>
<!-- Eventually replaced by eng/Version.targets -->
<Target Name="SetVersions" />
<Target Name="_UpdateTemplateVersions" DependsOnTargets="SetVersions">
<ItemGroup>
<_TemplateJsonFile Include="templates\*\.template.config\template.json" />

Просмотреть файл

@ -42,9 +42,6 @@
<Import Project="$(MauiRootDirectory)eng/ReplaceText.targets" />
<!-- Eventually replaced by eng/Version.targets -->
<Target Name="SetVersions" />
<Target Name="_GenerateBundledVersions"
BeforeTargets="Build;AssignTargetPaths"
DependsOnTargets="SetVersions"

Просмотреть файл

@ -17,9 +17,6 @@
<ProjectReference Include="../Microsoft.Maui.*/*.csproj" />
</ItemGroup>
<!-- Eventually replaced by eng/Version.targets -->
<Target Name="SetVersions" />
<Target Name="_GenerateWorkloadManifest" BeforeTargets="Build;AssignTargetPaths" DependsOnTargets="SetVersions" Inputs="$(MSBuildProjectFile);WorkloadManifest.in.json" Outputs="$(IntermediateOutputPath)WorkloadManifest.json">
<ReplaceText Input="WorkloadManifest.in.json" Output="$(IntermediateOutputPath)WorkloadManifest.json" OldValue="@VERSION@" NewValue="$(PackageReferenceVersion)" />
<ItemGroup>