Skip to content

Commit 3de3d1e

Browse files
authored
fix(windows): fix NuGet downloading 0.64 instead of canary builds (#1937)
1 parent ad49b91 commit 3de3d1e

File tree

2 files changed

+23
-20
lines changed

2 files changed

+23
-20
lines changed

windows/UWP/ReactTestApp.vcxproj

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="Current" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<Import Project="$(SolutionDir)ExperimentalFeatures.props" Condition="Exists('$(SolutionDir)ExperimentalFeatures.props')" />
4-
<Import Project="$(SolutionDir)packages\Microsoft.Windows.CppWinRT.2.0.211028.7\build\native\Microsoft.Windows.CppWinRT.props" Condition="$(ReactNativeWindowsVersionNumber)&lt;68000 AND Exists('$(SolutionDir)packages\Microsoft.Windows.CppWinRT.2.0.211028.7\build\native\Microsoft.Windows.CppWinRT.props')" />
4+
<Import Project="$(SolutionDir)packages\Microsoft.Windows.CppWinRT.2.0.211028.7\build\native\Microsoft.Windows.CppWinRT.props" Condition="$(ReactNativeWindowsVersionNumber)&gt;0 AND $(ReactNativeWindowsVersionNumber)&lt;68000 AND Exists('$(SolutionDir)packages\Microsoft.Windows.CppWinRT.2.0.211028.7\build\native\Microsoft.Windows.CppWinRT.props')" />
55
<PropertyGroup Label="Globals">
66
<CppWinRTOptimized>true</CppWinRTOptimized>
77
<CppWinRTRootNamespaceAutoMerge>true</CppWinRTRootNamespaceAutoMerge>
@@ -181,10 +181,10 @@
181181
</ItemGroup>
182182
<ItemGroup>
183183
<None Include="$(ProjectRootDir)\app.json" />
184-
<None Include="packages.config" Condition="$(ReactNativeWindowsVersionNumber)>=68000" />
184+
<None Include="packages.config" Condition="$(ReactNativeWindowsVersionNumber)==0 OR $(ReactNativeWindowsVersionNumber)>=68000" />
185185
<None Include="PropertySheet.props" />
186186
</ItemGroup>
187-
<ItemGroup Condition="$(ReactNativeWindowsVersionNumber)>=68000">
187+
<ItemGroup Condition="$(ReactNativeWindowsVersionNumber)==0 OR $(ReactNativeWindowsVersionNumber)>=68000">
188188
<PackageReference Include="nlohmann.json" Version="3.11.2" />
189189
</ItemGroup>
190190
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
@@ -203,12 +203,12 @@
203203
<ReactNativeWindowsVersion Condition="'$(ReactNativeWindowsVersion)'==''">$(ReactNativeWindowsNpmVersion)</ReactNativeWindowsVersion>
204204
</PropertyGroup>
205205
<ImportGroup Label="ExtensionTargets">
206-
<Import Project="$(SolutionDir)packages\Microsoft.Windows.CppWinRT.2.0.211028.7\build\native\Microsoft.Windows.CppWinRT.targets" Condition="$(ReactNativeWindowsVersionNumber)&lt;68000 AND Exists('$(SolutionDir)packages\Microsoft.Windows.CppWinRT.2.0.211028.7\build\native\Microsoft.Windows.CppWinRT.targets')" />
207-
<Import Project="$(SolutionDir)packages\Microsoft.ReactNative.$(ReactNativeWindowsVersion)\build\native\Microsoft.ReactNative.targets" Condition="$(ReactNativeWindowsVersionNumber)&lt;68000 AND Exists('$(SolutionDir)packages\Microsoft.ReactNative.$(ReactNativeWindowsVersion)\build\native\Microsoft.ReactNative.targets')" />
208-
<Import Project="$(SolutionDir)packages\Microsoft.ReactNative.Cxx.$(ReactNativeWindowsVersion)\build\native\Microsoft.ReactNative.Cxx.targets" Condition="$(ReactNativeWindowsVersionNumber)&lt;68000 AND Exists('$(SolutionDir)packages\Microsoft.ReactNative.Cxx.$(ReactNativeWindowsVersion)\build\native\Microsoft.ReactNative.Cxx.targets')" />
209-
<Import Project="$(SolutionDir)packages\ReactNative.Hermes.Windows.$(HermesVersion)\build\native\ReactNative.Hermes.Windows.targets" Condition="$(ReactNativeWindowsVersionNumber)&lt;68000 AND Exists('$(SolutionDir)packages\ReactNative.Hermes.Windows.$(HermesVersion)\build\native\ReactNative.Hermes.Windows.targets') AND '$(UseHermes)'=='true'" />
210-
<Import Project="$(SolutionDir)packages\$(WinUIPackageName).$(WinUIPackageVersion)\build\native\$(WinUIPackageName).targets" Condition="$(ReactNativeWindowsVersionNumber)&lt;68000 AND Exists('$(SolutionDir)packages\$(WinUIPackageName).$(WinUIPackageVersion)\build\native\$(WinUIPackageName).targets')" />
211-
<Import Project="$(SolutionDir)packages\nlohmann.json.3.11.2\build\native\nlohmann.json.targets" Condition="$(ReactNativeWindowsVersionNumber)&lt;68000 AND Exists('$(SolutionDir)packages\nlohmann.json.3.11.2\build\native\nlohmann.json.targets')" />
206+
<Import Project="$(SolutionDir)packages\Microsoft.Windows.CppWinRT.2.0.211028.7\build\native\Microsoft.Windows.CppWinRT.targets" Condition="$(ReactNativeWindowsVersionNumber)&gt;0 AND $(ReactNativeWindowsVersionNumber)&lt;68000 AND Exists('$(SolutionDir)packages\Microsoft.Windows.CppWinRT.2.0.211028.7\build\native\Microsoft.Windows.CppWinRT.targets')" />
207+
<Import Project="$(SolutionDir)packages\Microsoft.ReactNative.$(ReactNativeWindowsVersion)\build\native\Microsoft.ReactNative.targets" Condition="$(ReactNativeWindowsVersionNumber)&gt;0 AND $(ReactNativeWindowsVersionNumber)&lt;68000 AND Exists('$(SolutionDir)packages\Microsoft.ReactNative.$(ReactNativeWindowsVersion)\build\native\Microsoft.ReactNative.targets')" />
208+
<Import Project="$(SolutionDir)packages\Microsoft.ReactNative.Cxx.$(ReactNativeWindowsVersion)\build\native\Microsoft.ReactNative.Cxx.targets" Condition="$(ReactNativeWindowsVersionNumber)&gt;0 AND $(ReactNativeWindowsVersionNumber)&lt;68000 AND Exists('$(SolutionDir)packages\Microsoft.ReactNative.Cxx.$(ReactNativeWindowsVersion)\build\native\Microsoft.ReactNative.Cxx.targets')" />
209+
<Import Project="$(SolutionDir)packages\ReactNative.Hermes.Windows.$(HermesVersion)\build\native\ReactNative.Hermes.Windows.targets" Condition="$(ReactNativeWindowsVersionNumber)&gt;0 AND $(ReactNativeWindowsVersionNumber)&lt;68000 AND Exists('$(SolutionDir)packages\ReactNative.Hermes.Windows.$(HermesVersion)\build\native\ReactNative.Hermes.Windows.targets') AND '$(UseHermes)'=='true'" />
210+
<Import Project="$(SolutionDir)packages\$(WinUIPackageName).$(WinUIPackageVersion)\build\native\$(WinUIPackageName).targets" Condition="$(ReactNativeWindowsVersionNumber)&gt;0 AND $(ReactNativeWindowsVersionNumber)&lt;68000 AND Exists('$(SolutionDir)packages\$(WinUIPackageName).$(WinUIPackageVersion)\build\native\$(WinUIPackageName).targets')" />
211+
<Import Project="$(SolutionDir)packages\nlohmann.json.3.11.2\build\native\nlohmann.json.targets" Condition="$(ReactNativeWindowsVersionNumber)&gt;0 AND $(ReactNativeWindowsVersionNumber)&lt;68000 AND Exists('$(SolutionDir)packages\nlohmann.json.3.11.2\build\native\nlohmann.json.targets')" />
212212
<!-- ReactTestApp additional targets -->
213213
</ImportGroup>
214214
</Project>

windows/test-app.mjs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -306,17 +306,20 @@ export function generateSolution(destPath, options, fs = nodefs) {
306306
: fs.existsSync(nugetConfigPath0_64)
307307
? nugetConfigPath0_64
308308
: null;
309-
const nugetConfigDestPath = path.join(destPath, "NuGet.Config");
310-
if (nugetConfigPath && !fs.existsSync(nugetConfigDestPath)) {
311-
copyTasks.push(
312-
writeTextFile(
313-
nugetConfigDestPath,
314-
mustache.render(readTextFile(nugetConfigPath, fs), {
315-
nuGetADOFeed: info.version.startsWith("0.0.0-"),
316-
}),
317-
fs.promises
318-
)
319-
);
309+
if (nugetConfigPath) {
310+
const nugetConfigDest = path.join(destPath, "NuGet.Config");
311+
const nugetConfigCopy = path.join(projectFilesDestPath, "NuGet.Config");
312+
if (fs.existsSync(nugetConfigDest)) {
313+
copyTasks.push(fs.promises.cp(nugetConfigDest, nugetConfigCopy));
314+
} else {
315+
const template = readTextFile(nugetConfigPath, fs);
316+
const nuGetADOFeed = info.version.startsWith("0.0.0-");
317+
const nugetConfig = mustache.render(template, { nuGetADOFeed });
318+
copyTasks.push(
319+
writeTextFile(nugetConfigDest, nugetConfig, fs.promises),
320+
writeTextFile(nugetConfigCopy, nugetConfig, fs.promises)
321+
);
322+
}
320323
}
321324
}
322325

0 commit comments

Comments
 (0)