Fix `yarn install` run in VS project builds (#10747)
* Fix `yarn check` and use it for VS projects * Fix RN and RNW resolution versions * Run `yarn check` after `yarn install` and in CI * Change integrate-rn to update resolution entries * Remove `yarn check` from CI * Remove yarn check from postinstall * Change files * Set the CI Setup timeout to 6 minutes * Restore use of yarn check * Set the Setup timeout back to 3 minutes * Revert changes for `yarn check` * Run yarn install --frozen-lockfile * Add missing project dependencies * Change files * Restore order of configuration platform selection * Remove dependency to see if it fixes build * Revert "Remove dependency to see if it fixes build" This reverts commit890f770796
. * Revert "Revert "Remove dependency to see if it fixes build"" This reverts commit0bf7c02a92
. * Remove duplicated properties Co-authored-by: Vladimir Morozov <vmoroz@users.noreply.github.com>
This commit is contained in:
Родитель
d1ee32893c
Коммит
c69cb614d1
|
@ -21,6 +21,8 @@
|
|||
<BaseIntDir Condition="'$(Platform)' != 'Win32'">$(RootIntDir)\$(Platform)\$(Configuration)</BaseIntDir>
|
||||
<BaseOutDir Condition="'$(Platform)' == 'Win32'">$(RootOutDir)\x86\$(Configuration)</BaseOutDir>
|
||||
<BaseOutDir Condition="'$(Platform)' != 'Win32'">$(RootOutDir)\$(Platform)\$(Configuration)</BaseOutDir>
|
||||
|
||||
<ReactNativeYarnIntDir>$(RootIntDir)\yarn_install\</ReactNativeYarnIntDir>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Label="NuGet">
|
||||
|
|
|
@ -1,59 +1,64 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project>
|
||||
|
||||
<!-- This target is used to compute the inputs and outputs for incrementally running the Yarn up to date check.-->
|
||||
<!-- This target is used to compute the inputs and outputs for running the `yarn install`. -->
|
||||
<Target
|
||||
Name="EnsureJavaScriptCodeUpToDateInputAndOutputs"
|
||||
Name="ReactNativeYarnInstallInputAndOutputs"
|
||||
>
|
||||
<ItemGroup>
|
||||
<_EnsureJavaScriptCodeUpToDateInputFiles Include="$(MSBuildThisFileDirectory)yarn.lock" />
|
||||
<_EnsureJavaScriptCodeUpToDateInputFiles Include="$(MSBuildThisFileDirectory)\**\package.json" Exclude="$(MSBuildThisFileDirectory)\node_modules\**" />
|
||||
<_EnsureJavaScriptCodeUpToDateOutputFiles Include="@(_EnsureJavaScriptCodeUpToDateInputFiles->'$(IntDir)\JsUpToDateCheck\%(RecursiveDir)%(Filename)%(Extension).dummy')" />
|
||||
<_ReactNativeYarnInstallInputFiles Include="$(MSBuildThisFileDirectory)yarn.lock" />
|
||||
<_ReactNativeYarnInstallInputFiles Include="$(MSBuildThisFileDirectory)**\package.json" Exclude="$(MSBuildThisFileDirectory)node_modules\**" />
|
||||
<_ReactNativeYarnInstallOutputFiles Include="@(_ReactNativeYarnInstallInputFiles->'$(ReactNativeYarnIntDir)%(RecursiveDir)%(Filename)%(Extension).dummy')" />
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
|
||||
<!--
|
||||
This target checks if Yarn install needs to run or not.
|
||||
This is a common cause of failed builds for developers not used to running it after syncing...
|
||||
This check does not run during design time build and in our CI validation runs (detected via AGENT_NAME).
|
||||
This target runs `yarn install` and then `yarn build` as a post install step in `package.json`.
|
||||
This is to address build failures by not running `yarn install` after syncing.
|
||||
We do not run `yarn install` during design time build and in our CI validation runs (detected via AGENT_NAME).
|
||||
-->
|
||||
<Target
|
||||
Name="EnsureJavaScriptCodeUpToDate"
|
||||
Name="ReactNativeYarnInstall"
|
||||
BeforeTargets="BeforeBuild"
|
||||
DependsOnTargets="EnsureJavaScriptCodeUpToDateInputAndOutputs"
|
||||
Inputs="@(_EnsureJavaScriptCodeUpToDateInputFiles)"
|
||||
Outputs="@(_EnsureJavaScriptCodeUpToDateOutputFiles)"
|
||||
DependsOnTargets="ReactNativeYarnInstallInputAndOutputs"
|
||||
Inputs="@(_ReactNativeYarnInstallInputFiles)"
|
||||
Outputs="@(_ReactNativeYarnInstallOutputFiles)"
|
||||
Condition="'$(DesignTimeBuild)'=='' AND '$(AGENT_NAME)' == ''"
|
||||
>
|
||||
|
||||
<Message Text="Checking if yarn is 'up to date' by running a 'dry-run' version of `yarn install` and checking the exit code" />
|
||||
<Message Text="Running yarn install to fetch latest packages." Importance="High" />
|
||||
<Message Text="yarn install --frozen-lockfile --mutex file:.yarn-mutex" Importance="High" />
|
||||
<Exec
|
||||
ContinueOnError="True"
|
||||
Command="yarn install --offline --cache-folder $(IntDir)\JsUpToDateCheck\Cache"
|
||||
Command="yarn install --frozen-lockfile --mutex file:.yarn-mutex"
|
||||
WorkingDirectory="$(MSBuildThisFileDirectory)"
|
||||
>
|
||||
<Output TaskParameter="ExitCode" ItemName="_YarnExitCode"/>
|
||||
<Output TaskParameter="ExitCode" ItemName="_ReactNativeYarnExitCode"/>
|
||||
</Exec>
|
||||
|
||||
<Message Text="yarn install: Succeeded" Condition="'%(_ReactNativeYarnExitCode.Identity)' == '0'" Importance="High" />
|
||||
<Message Text="yarn install: Failed" Condition="'%(_ReactNativeYarnExitCode.Identity)' != '0'" Importance="High" />
|
||||
|
||||
<!-- Fail the build if yarn needs to install packages. -->
|
||||
<!-- Fail the build if yarn needs to update yarn.lock file. -->
|
||||
<Error
|
||||
Condition="'%(_YarnExitCode.Identity)' != '0'"
|
||||
Text="Yarn packages are out of date. Please run `yarn install && yarn build` in the root of the repo to ensure the generated files are up to date"
|
||||
Condition="'%(_ReactNativeYarnExitCode.Identity)' != '0'"
|
||||
Text="Yarn packages are out of date. Please run `yarn install` in the root of the repo to ensure the generated files are up to date"
|
||||
/>
|
||||
|
||||
<!--
|
||||
Copy the yarn.lock file to prevent this task from running over and over again, and only rerun the check with yarn.lock or any package.json changes.
|
||||
This will likely miss a few corner cases with local changes to package.json but should catch the most important case after syncing
|
||||
-->
|
||||
<MakeDir Directories="$(ReactNativeYarnIntDir)" />
|
||||
<Copy
|
||||
Condition="'%(_YarnExitCode.Identity)' == '0'"
|
||||
SourceFiles="@(_EnsureJavaScriptCodeUpToDateInputFiles)"
|
||||
DestinationFiles="@(_EnsureJavaScriptCodeUpToDateOutputFiles)"
|
||||
Condition="'%(_ReactNativeYarnExitCode.Identity)' == '0'"
|
||||
SourceFiles="@(_ReactNativeYarnInstallInputFiles)"
|
||||
DestinationFiles="@(_ReactNativeYarnInstallOutputFiles)"
|
||||
SkipUnchangedFiles="true"
|
||||
Retries="5"
|
||||
RetryDelayMilliseconds="100" />
|
||||
<!-- We have to touch the outputs to ensure up to date incrementaility works-->
|
||||
<Touch Files="@(_EnsureJavaScriptCodeUpToDateOutputFiles)" />
|
||||
<Touch Files="@(_ReactNativeYarnInstallOutputFiles)" />
|
||||
|
||||
</Target>
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"type": "prerelease",
|
||||
"comment": "Run yarn install --frozen-lockfile",
|
||||
"packageName": "react-native-windows",
|
||||
"email": "vmoroz@users.noreply.github.com",
|
||||
"dependentChangeType": "patch"
|
||||
}
|
|
@ -108,6 +108,9 @@ EndProject
|
|||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{CF71BDBF-544C-4EBC-85F6-6911A0E2F5B8}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.ReactNative.Managed.CodeGen.UnitTests", "Microsoft.ReactNative.Managed.CodeGen.UnitTests\Microsoft.ReactNative.Managed.CodeGen.UnitTests.csproj", "{0F4DBB0D-659A-4330-845F-E77204F90B12}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{F7D32BD0-2749-483E-9A0D-1635EF7E3136} = {F7D32BD0-2749-483E-9A0D-1635EF7E3136}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.ReactNative.Managed.CodeGen", "Microsoft.ReactNative.Managed.CodeGen\Microsoft.ReactNative.Managed.CodeGen.csproj", "{ADED4FBE-887D-4271-AF24-F0823BCE7961}"
|
||||
EndProject
|
||||
|
|
Загрузка…
Ссылка в новой задаче