Open arsenikstiger opened 2 years ago
I tried to pass experimentalNuGetDependency to true, by following this tutorial This bug doesn't occur anymore. So I think this can be marked as a workaround.
I tried to pass experimentalNuGetDependency to true, by following this tutorial This bug doesn't occur anymore. So I think this can be marked as a workaround.
Glad you're unblocked. Requiring that you use the experimental nuget and not be able to build from source may not work for everyone. So there's still a gap here.
This could be related to RNW's enablement of PackageReference
for C++ NuGet dependencies.
I will investigate in depth tomorrow.
Hi @arsenikstiger.
Can you please specify what PInvoke
NuGet package did you add?
There doesn't seem to be a package with that exact name in nuget.org.
Following the mentioned steps but adding NuGet dependency PInvoke.Windows.Core
, the issue does not reproduce.
I'm also trying to create a react-native windows with c#. Just like the OP, if I go through the steps on the getting started page and never open the visual studio solution, the app starts. However, if I open the visual studio solution (I did NOT change any of the code) and try to run "npx react-native run-windows", I also get the following:
× Building Solution: C:[path to project]\node_modules\react-native-window... × Build failed with message C:[path to project]\node_modules\react-native-windows\Microsoft.ReactNative.Managed.CodeGen\build\x64\Debug\Microsoft.ReactNative.Managed.CodeGen\netcoreapp3.1\win-x64.NETCoreApp,Version=v3.1.AssemblyAttributes.cs(4,12): error CS0579: Duplicate 'global::System.Runtime.Versioning.TargetFrameworkAttribute' attribute [C:[path to project]\node_modules\react-native-windows\Microsoft.ReactNative.Managed.CodeGen\Microsoft.ReactNative.Managed.CodeGen.csproj]. Check your build configuration.
In addition, this sequence:
npx react-native init
gives the following build failed error from visual studio
Error Could not write lines to file "build\x64\Debug\Microsoft.ReactNative.Managed.CodeGen\netcoreapp3.1\win-x64\Microsoft.ReactNative.Managed.CodeGen.GeneratedMSBuildEditorConfig.editorconfig". Could not find a part of the path '[path to project]\node_modules\react-native-windows\Microsoft.ReactNative.Managed.CodeGen\build\x64\Debug\Microsoft.ReactNative.Managed.CodeGen\netcoreapp3.1\win-x64\Microsoft.ReactNative.Managed.CodeGen.GeneratedMSBuildEditorConfig.editorconfig'. [name of project]
My version info:
windows 10.0.19043
Microsoft Visual Studio Community 2019 Version 16.11.17 VisualStudio.16.Release/16.11.17+32630.194 Microsoft .NET Framework Version 4.8.04084 Installed Version: Community Visual C++ 2019 00435-00000-00000-AA918 Microsoft Visual C++ 2019
react-native - 0.69.0 node - v14.18.1
EDIT - The 1st and 2nd issue I printed above were fixed by moving my project location closer to root. I had a hunch that the path was getting too long. I noted the "enable long path support" in the "likely out of date" instruction before I started and looked this up and changed a value in the registry. Did I not do this correctly? I have no way of knowing. Can someone tell me a workaround or the correct way to 'enable long path support', I'd like to not have to name my projects without vowels and place them right on the C drive, lol.
I want to upgrade my app from 0.65 to 0.69 and i always do working Hello World app before upgrade to see all needed changes.
I tried to build React Native Windows Hello World app on 0.69.3 and i get about the same build errors.
Steps to create C# HelloWorld 0.69.3. I ran these command in root to prevent paths to get too long.
npx react-native init Hello069 --template react-native@0.69.3
cd Hello069
yarn install
npx react-native-windows-init --overwrite --language cs --version 0.69.4
I opened solution file by Visual Studio 2019 (16.11.6) and tried x64 debug build (Build->Build solution).
I get assembly build errors:
8>C:\Users\tepaa\Hello069\node_modules\react-native-windows\Microsoft.ReactNative.Managed.CodeGen\build\x64\Debug\Microsoft.ReactNative.Managed.CodeGen\netcoreapp3.1\win-x64\.NETCoreApp,Version=v3.1.AssemblyAttributes.cs(4,12,4,70): error CS0579: Duplicate 'global::System.Runtime.Versioning.TargetFrameworkAttribute' attribute
8>C:\Users\tepaa\Hello069\node_modules\react-native-windows\Microsoft.ReactNative.Managed.CodeGen\build\x64\Debug\Microsoft.ReactNative.Managed.CodeGen\netcoreapp3.1\win-x64\Microsoft.ReactNative.Managed.CodeGen.AssemblyInfo.cs(14,12,14,54): error CS0579: Duplicate 'System.Reflection.AssemblyCompanyAttribute' attribute
8>C:\Users\tepaa\Hello069\node_modules\react-native-windows\Microsoft.ReactNative.Managed.CodeGen\build\x64\Debug\Microsoft.ReactNative.Managed.CodeGen\netcoreapp3.1\win-x64\Microsoft.ReactNative.Managed.CodeGen.AssemblyInfo.cs(15,12,15,60): error CS0579: Duplicate 'System.Reflection.AssemblyConfigurationAttribute' attribute
8>C:\Users\tepaa\Hello069\node_modules\react-native-windows\Microsoft.ReactNative.Managed.CodeGen\build\x64\Debug\Microsoft.ReactNative.Managed.CodeGen\netcoreapp3.1\win-x64\Microsoft.ReactNative.Managed.CodeGen.AssemblyInfo.cs(16,12,16,58): error CS0579: Duplicate 'System.Reflection.AssemblyFileVersionAttribute' attribute
8>C:\Users\tepaa\Hello069\node_modules\react-native-windows\Microsoft.ReactNative.Managed.CodeGen\build\x64\Debug\Microsoft.ReactNative.Managed.CodeGen\netcoreapp3.1\win-x64\Microsoft.ReactNative.Managed.CodeGen.AssemblyInfo.cs(17,12,17,67): error CS0579: Duplicate 'System.Reflection.AssemblyInformationalVersionAttribute' attribute
8>C:\Users\tepaa\Hello069\node_modules\react-native-windows\Microsoft.ReactNative.Managed.CodeGen\build\x64\Debug\Microsoft.ReactNative.Managed.CodeGen\netcoreapp3.1\win-x64\Microsoft.ReactNative.Managed.CodeGen.AssemblyInfo.cs(18,12,18,54): error CS0579: Duplicate 'System.Reflection.AssemblyProductAttribute' attribute
8>C:\Users\tepaa\Hello069\node_modules\react-native-windows\Microsoft.ReactNative.Managed.CodeGen\build\x64\Debug\Microsoft.ReactNative.Managed.CodeGen\netcoreapp3.1\win-x64\Microsoft.ReactNative.Managed.CodeGen.AssemblyInfo.cs(19,12,19,52): error CS0579: Duplicate 'System.Reflection.AssemblyTitleAttribute' attribute
8>C:\Users\tepaa\Hello069\node_modules\react-native-windows\Microsoft.ReactNative.Managed.CodeGen\build\x64\Debug\Microsoft.ReactNative.Managed.CodeGen\netcoreapp3.1\win-x64\Microsoft.ReactNative.Managed.CodeGen.AssemblyInfo.cs(20,12,20,54): error CS0579: Duplicate 'System.Reflection.AssemblyVersionAttribute' attribute
Warning
Severity Code Description Project File Line Suppression State
Warning The project 'Microsoft.ReactNative' cannot be referenced. The referenced project is targeted to a different framework family (native) Hello069
System:
OS: Windows 10 10.0.19044
CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
Memory: 21.35 GB / 31.90 GB
Binaries:
Node: 14.20.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 8.11.0 - C:\Program Files\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK: Not Found
Windows SDK:
AllowDevelopmentWithoutDevLicense: Enabled
AllowAllTrustedApps: Enabled
Versions: 10.0.18362.0, 10.0.19041.0
IDEs:
Android Studio: Not Found
Visual Studio: 16.11.31829.152 (Visual Studio Community 2019)
Languages:
Java: Not Found
npmPackages:
@react-native-community/cli: Not Found
react: Not Found
react-native: 0.69.3 => 0.69.3
react-native-windows: 0.69.4 => 0.69.4
npmGlobalPackages:
*react-native*: Not Found
RNW 0.68 C# HelloWorld builds without errors
npx react-native init Hello068 --template react-native@0.68.2
cd Hello068
yarn install
npx react-native-windows-init --overwrite --language cs --version 0.68.12
I managed first time to build 0.69.6 C# HelloWorld on Visual Studio 2019 (x64 Debug) without duplicate errors for example
"CS0579: Duplicate 'global::System.Runtime.Versioning.TargetFrameworkAttribute' [[project-path]\node_modules\react-native-windows\Microsoft.ReactNative.Managed.CodeGen\Microsoft.ReactNative.Managed.CodeGen.csproj]. Check your build configuration."
by adding these lines
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
into node_modules\react-native-windows\Microsoft.ReactNative.Managed.CodeGen\Microsoft.ReactNative.Managed.CodeGen.csproj
BUT some challenges with the release build...it is white screen. White screen bug may be fixed on RNW 0.70 and will come later on 0.69...
My C# HelloWorld app for test this issue
npx react-native init Hello069 --template react-native@0.69.4
cd Hello069
yarn install
npx react-native-windows-init --overwrite --language cs --version 0.69.6
C++ version of the HelloWorld app builds without errors.
I am having the same issue. Rolling back to 0.68 did indeed work. Are there any fixes for newer versions already?
I'm also seeing this after upgrading from 0.68.0 to 0.69.0. Is there any guidance on this?
I'm also seeing this after upgrading from 0.68.0 to 0.69.0. Is there any guidance on this?
Above is my solution
https://github.com/microsoft/react-native-windows/issues/10236#issuecomment-1240577791
I'm also seeing this after upgrading from 0.68.0 to 0.69.0. Is there any guidance on this?
Above is my solution
Thank you for the workaround, but you also mentioned "BUT some challenges with the release build...it is white screen.", so I assume this is still a problem?
I'm also seeing this after upgrading from 0.68.0 to 0.69.0. Is there any guidance on this?
Above is my solution #10236 (comment)
Thank you for the workaround, but you also mentioned "BUT some challenges with the release build...it is white screen.", so I assume this is still a problem?
Not anymore white screen issue with latest 0.69 version on release build
Where specifically did you put those lines of code? Your answer is not very specific
Where specifically did you put those lines of code? Your answer is not very specific
node_modules\react-native-windows\Microsoft.ReactNative.Managed.CodeGen\Microsoft.ReactNative.Managed.CodeGen.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Platforms>x64;x86;ARM;ARM64</Platforms>
<RuntimeIdentifiers>win-x86;win-x64</RuntimeIdentifiers>
<Platform>x64</Platform>
<!-- We are a tool, so on all platforms force win-x64 -->
<PlatformTarget>x64</PlatformTarget>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<Nullable>enable</Nullable>
<LangVersion>8.0</LangVersion>
<! -- TO GET 0.69 C# APP BUILD -->
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
</PropertyGroup>
...
but i of course hope that some in Microsoft gives validated fix for this issue
Let's hope so. Thank you for your help @tero-paananen!
@chrisglein @JunielKatarn, Can we get any insight on this issue? I do not see this every time I attempt a release build. For example, I just restarted my machine and ran npx react-native run-windows --release
, and my app was built successfully. I kill the app, open Visual Studio 2022, run npx react-native run-windows --release
, and then run into the error.
@haightt Can you share the sources/branch you are working on to try and follow the same exact steps?
This looks like a very particular corner case.
I cannot. This is happening attempting to upgrade our company's app.
@JunielKatarn Now I am getting this in Visual Studio
@haightt would you be willing to share a binary build log privately?
If so, please follow these steps:
MSBuild.exe <your solution> /t:Restore '/p:RestoreProjectStyle=PackagesConfig;RestorePackagesConfig=true' /bl:pkgcnf.binlog
MSBuild.exe <your solution> /restore /bl:pkgref.binlog
This should generate two .binlog
files: pkgcnf.binlog
and pkgref.binlog
.
@JunielKatarn Now I am getting this in Visual Studio
My solution for this error was define for example <WindowsTargetPlatformVersion>10.0.19041.0</WindowsTargetPlatformVersion>
into ExperimentalFeatures.props file.
Idea for this is force all modules to use same versions (target, min, max target platform version).
Clean and rebuild all...
@JunielKatarn I was able to generate the .binlog
file from the second command. However, the first results in the error MSB1008: Only one project can be specified
@haightt there is likely more than one project or solution file in that directory (.vcxproj
, .csproj
, .sln
).
Please try again using the specific project file you want to log as a command argument.
@JunielKatarn, I was able to generate both of those files. How would you like me to share them with you?
@haightt
Please do.
I created a basic new react-native-windows
app and ran into the same issue when performing a release build. I am confused as to what is going on here. I did this to eliminate the possibility that one of the packages we use is causing the build issue. Here's what I did:
--language cs
flag to create a C# windows app.npx react-native run-windows
. This was built successfully, and I got the boilerplate starting screen.npx react-native run-windows --release
. This fails with the global::System.Runtime.Versioning.TargetFrameworkAttribute
error.npx react-native run-windows
. This now fails with the duplicate framework error.Here is the repo for that bare app: https://github.com/haightt/RNW070. I don't know how helpful that is, as I didn't change any code here; I just initialized the app.
Our C# app is now on RNW 0.70.10 and have to still use flags <GenerateAssemblyInfo>false</GenerateAssemblyInfo <GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
in react-native-windows\Microsoft.ReactNative.Managed.CodeGen\Microsoft.ReactNative.Managed.CodeGen.csproj
I get a consistent repro with the steps provided by @haightt. Researching.
@JunielKatarn, Any updates on this issue?
No progress so far. I'll update this issue when a workaround/fix is found.
I cannot build even with the above @tero-paananen solution above. react-native-windows version: 0.70.11 react-native version: 0.70
any help or workaround would be appreciated thanks
I cannot build even with the above @tero-paananen solution above. react-native-windows version: 0.70.11 react-native version: 0.70
any help or workaround would be appreciated thanks
What was the error?
CS0579 Duplicate error, i fixed it by commenting out the duplicate references inside of Microsoft.managed.codegen Assembly.Info.cs file
I managed to "solve" all duplicate or write errors of Microsoft.ReactNative.Managed.CodeGen.csproj
changing Visual Studio to RELEASE build only 1 project at the time.
Unable to use package assets cache due to I/O error.
This can occur when the same project is built more than once in parallel. Performance may be degraded, but the build result will not be impacted.
Could not write lines to file "build\x64\Release\Microsoft.ReactNative.Managed.CodeGen\netcoreapp3.1\win-x64\Microsoft.ReactNative.Managed.CodeGen.GeneratedMSBuildEditorConfig.editorconfig".
Could not find a part of the path 'C:\Users\xxxxx\node_modules\react-native-windows\Microsoft.ReactNative.Managed.CodeGen\build\x64\Release\Microsoft.ReactNative.Managed.CodeGen\netcoreapp3.1\win-x64\Microsoft.ReactNative.Managed.CodeGen.GeneratedMSBuildEditorConfig.editorconfig'.
The workaround makes sense, but we will still investigate this bug. Building in parallel should not cause a failure. Apparently, some intermediate artifact directory path is being used for multiple projects.
I am currently dealing with unrelated high priority bugs but the issue is still under our radar.
The above solution of disabling parallel builds did not work in our case.
The above solution of disabling parallel builds did not work in our case.
I'm having the same issue on release build. Also no joy with disabling parallel builds. Any other solution?
Notably, when building in release, it seems that the error that I am getting is in a debug build for the windows node module path as shown below.
Severity Code Description Project File Line Suppression State Error Duplicate 'global::System.Runtime.Versioning.TargetFrameworkAttribute' attribute C:\projectpath\node_modules\react-native-windows\Microsoft.ReactNative.Managed.CodeGen\build\x64\Debug\Microsoft.ReactNative.Managed.CodeGen\netcoreapp3.1\win-x64.NETCoreApp,Version=v3.1.AssemblyAttributes.cs 5
Notably, when building in release, it seems that the error that I am getting is in a debug build for the windows node module path as shown below.
Severity Code Description Project File Line Suppression State Error Duplicate 'global::System.Runtime.Versioning.TargetFrameworkAttribute' attribute C:\projectpath\node_modules\react-native-windows\Microsoft.ReactNative.Managed.CodeGen\build\x64\Debug\Microsoft.ReactNative.Managed.CodeGen\netcoreapp3.1\win-x64.NETCoreApp,Version=v3.1.AssemblyAttributes.cs 5
Even this does not work ? https://github.com/microsoft/react-native-windows/issues/10236#issuecomment-1371842540
Remember to clean build after changing that config. Restart VS and make full build again.
C:\projectpath\node_modules\react-native-windows\Microsoft.ReactNative.Managed.CodeGen\build\x64\Debug\Microsoft.ReactNative.Managed.CodeGen\netcoreapp3.1\win-x64.NETCoreApp,Version=v3.1.AssemblyAttributes.cs @acaininet simply go to the path and comment all of the references there.
I had done a build 'clean' in Visual Studio, with the same issues. However, I manually deleted all build folders/files from the Microsoft.ReactNative.Managed.Codegen project and have been able to build and deploy both release and debug packages. (Release, Debug, then Release again to confirm continued functionality.) Thank you.
<! -- TO GET 0.69 C# APP BUILD -->
false <GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
Where specifically did you put those lines of code? Your answer is not very specific
node_modules\react-native-windows\Microsoft.ReactNative.Managed.CodeGen\Microsoft.ReactNative.Managed.CodeGen.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>netcoreapp3.1</TargetFramework> <Platforms>x64;x86;ARM;ARM64</Platforms> <RuntimeIdentifiers>win-x86;win-x64</RuntimeIdentifiers> <Platform>x64</Platform> <!-- We are a tool, so on all platforms force win-x64 --> <PlatformTarget>x64</PlatformTarget> <RuntimeIdentifier>win-x64</RuntimeIdentifier> <Nullable>enable</Nullable> <LangVersion>8.0</LangVersion> <! -- TO GET 0.69 C# APP BUILD --> <GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute> </PropertyGroup> ...
Thanks @tero-paananen! Your workaround solution is only one that works for me in the case. Looking forward a fix.
Problem Description
I created a project by following instructions on get-started for react-native for windows, and choosed C#. I created the project today, so I use the last version. The 1st start of the project was good.
But as soon as I modifiy the .NET project to include my own code and nuget dependencies (PInvoke), I encounter this problem when building my project with react-native run-windows command:
Build failed with message 9:6>[project-path]\node_modules\react-native-windows\Microsoft.ReactNative.Managed.CodeGen\build\x64\Debug\Microsoft.ReactNative.Managed.CodeGen\netcoreapp3.1\win-x64.NETCoreApp,Version=v3.1.AssemblyAttributes.cs(4,12): error CS0579: Duplicate 'global::System.Runtime.Versioning.TargetFrameworkAttribute' [[project-path]\node_modules\react-native-windows\Microsoft.ReactNative.Managed.CodeGen\Microsoft.ReactNative.Managed.CodeGen.csproj]. Check your build configuration.
I tried to clean the project from VS2022, but no results.
Steps To Reproduce
Expected Results
It has to build and launch my project !
CLI version
8.0.2
Environment
Target Platform Version
10.0.19041
Target Device(s)
Desktop
Visual Studio Version
Visual Studio 2022
Build Configuration
Debug
Snack, code example, screenshot, or link to a repository
No response