Skip to content

duplicate 'global::System.Runtime.Versioning.TargetFrameworkAttribute' when launching run-windows #10236

@arsenikstiger

Description

@arsenikstiger

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

  1. Create react-native for windows project with C#
  2. Open project sln with Visual Studio 2022
  3. Add some code and include a nuget dependency (PInvoke in my case)
  4. Run npx react-native run-windows

Expected Results

It has to build and launch my project !

CLI version

8.0.2

Environment

Languages:
    Java: javac 17 - C:\Program Files\Eclipse Foundation\jdk-17.0.0.35-hotspot\bin\javac.EXE
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.0.0 => 18.0.0
    react-native: 0.69.0 => 0.69.0
    react-native-windows: ^0.69.1 => 0.69.1
  npmGlobalPackages:
    *react-native*: Not Found

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions