-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RNW 0.68 run-windows fails nuget restore when project depends on C# Native Modules #10059
Comments
Can you provide more details? Are you trying to add a C# native module to a C++ app project? Docs on starting new native modules are here: https://microsoft.github.io/react-native-windows/docs/native-modules-setup |
@jonthysell just tested these steps for adding react-native-document-picker to a minimal rn-windows install and it reproduces the issue
^ This will work, installs react-native 0.68.2 and react-native-windows 0.68.5
This will result in this error
|
Not sure if that's an issue with react-native-document-picker itself but we also are seeing similar errors in our own builds |
This issue lacks the environment info requested in the bug template. Please edit your issue report to add this information. If you are using latest version:
Otherwise if
|
1 . First create the native module with like in documentation: https://microsoft.github.io/react-native-windows/docs/native-modules-setup
2 - Create new Project like in documentation: https://microsoft.github.io/react-native-windows/docs/getting-started
3 - Add the native module to package.json of project |
@JunielKatarn It looks like there's a problem with C++ apps consuming C# modules during the nuget restore. You applied a fix for sample-apps, but that doesn't help everyone else. For the c++ app vcxproj: <PropertyGroup Label="NuGet">
<ResolveNuGetPackages>false</ResolveNuGetPackages>
<!-- https://github.com/NuGet/Home/issues/10511#issuecomment-778400668 -->
<AssetTargetFallback>$(AssetTargetFallback);uap10.0.16299</AssetTargetFallback>
</PropertyGroup> For the C# module csproj: <PropertyGroup Label="NuGet">
<AssetTargetFallback>$(AssetTargetFallback);native</AssetTargetFallback>
</PropertyGroup> Can you look at moving that logic to the external property sheets so everyone gets it? |
Same problem here, followed microsoft guides to create the native module but it's failing when added to the app. Any workaround to fix this? |
@andrelimawork There are a couple bugs here that need to be resolved. As in my previous comment, there's some build properties that need to be set in both the C++ app and the C# native module to resolve this error. We did it locally in our sample-app projects, but not in a place that would be picked up by other projects. As a workaround, you could manually add those changes yourself to your app and module project files, however the correct fix on our end would be to either
Furthermore, even if you apply the changes in @maribeiroleya 's case, the
The module was built on an older module project template and so uses a different (older) Windows SDK version than the app project. The module uses: <TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.18362.0</TargetPlatformVersion> Where-as a new app uses: <TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.19041.0</TargetPlatformVersion> To workaround this, you could try to add a file named <?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<TargetPlatformVersion>10.0.19041.0</TargetPlatformVersion>
</PropertyGroup>
</Project> However a real fix would be for us to either update our imports to set that automatically on behalf of the modules (which might break other modules) or, even better, for the owners of |
Sorry, but i've created a new module via npx: ReactNativeModule.cs
ReactPackageProvider.cs:
I've followed the steps in the react native windows docs but i still get the error when the module it's added to the app project. The" newer template" it's not created by default when we create a new project with |
👍 Just another vote for figuring this out for 0.69.2 or 0.70.0, as we need to be able to upgrade in order to fix another issue that has been deferred to one of those. |
Creating a Directory.Build.props file in the root of an example app consuming ReactNativeFileViewer enabled the build to succeed. File contents:
|
I managed to build c# module in c# app (react-native-windows 0.68) with following configs App.csproj
App's ExperimentalFeatures.props
c# module csproj
I am not sure if all really needed... |
I still needed my hack above when build our C# RNW app package from Some tips from us:
Note also these files at least on RNW 0.73 and usage of them is about
VS restore NuGet does not works currently for some reason. To get restore work i have to call Nuget restore error from Visual Studio 2022 is |
Problem Description
Hi,
I am trying to add a Native Module in C# to my project, but give the error:
Project ReactNativeFileViewer is not compatible with native (native,Version=v0.0). Project ReactNativeFileViewer supports: uap10.0.16299 (UAP,Version=v10.0.16299)
Steps To Reproduce
1 . First create the native module with like in documentation: https://microsoft.github.io/react-native-windows/docs/native-modules-setup
2 - Create new Project like in documentation: https://microsoft.github.io/react-native-windows/docs/getting-started
3 - Add the native module to package.json of project
4 - npm i to install module
5 - Autolink the native module
6 - Run in VS x86
Expected Results
No response
CLI version
npx react-native --version
Environment
Target Platform Version
No response
Target Device(s)
No response
Visual Studio Version
2019
Build Configuration
No response
Snack, code example, screenshot, or link to a repository
No response
The text was updated successfully, but these errors were encountered: