Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

NFProjectSystem.CSharp.targets import failed in SDK Style project #1634

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

Closed
wherewhere opened this issue May 4, 2025 · 1 comment
Closed

Comments

@wherewhere
Copy link

Tool

Visual Studio extension

Description

I am trying to target netnano1.0 in SDK Style project. It works fine when I import NFProjectSystem.CSharp.targets in .nfproj. But when I try to move it to Directory.Build.targets, it failed with
image

Because the NFProjectSystem.CSharp.targets has imports the Microsoft.CSharp.CurrentVersion.targets and the SDK imports it again.

It also warning when import it in .nfproj.
warning MSB4011: 无法再次导入“C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\amd64\Microsoft.Common.targets”。可能已在“C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\amd64\Microsoft.CSharp.CurrentVersion.targets (348,5)”处导入过它。这很可能是生成创作错误。将忽略此后续导入。[C:\Users\qq251\Downloads\GitHub\new\NFApp1\NFApp1\NFApp1.nfproj]

#1067

How to reproduce

Directory.Build.props

<Project>
  
  <PropertyGroup Condition="$(MSBuildProjectExtension) == '.nfproj'">
    <AssetTargetFallback>$(AssetTargetFallback);net</AssetTargetFallback>
    <NoWarn>$(NoWarn);NU1701</NoWarn>
    <NanoFrameworkProjectSystemPath Condition="$(NanoFrameworkProjectSystemPath) == ''">$(MSBuildExtensionsPath)\nanoFramework\v1.0\</NanoFrameworkProjectSystemPath>
  </PropertyGroup>
  
  <Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.Default.props" Condition="$(MSBuildProjectExtension) == '.nfproj' and Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.Default.props')" />
  <Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.props" Condition="$(MSBuildProjectExtension) == '.nfproj' and Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.props')" />

</Project>

Directory.Build.targets

<Project>

  <ItemGroup>
    <PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="all">
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
  </ItemGroup>
  
  <ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'netnano'))">
    <PackageReference Include="nanoFramework.CoreLibrary.NoReflection" Version="1.17.12" />
  </ItemGroup>
  
</Project>

.nfproj

<Project Sdk="Microsoft.NET.Sdk">
  
  <PropertyGroup>
    <LangVersion>latest</LangVersion>
    <OutputType>Exe</OutputType>
    <TargetFramework>netnano1.0</TargetFramework>
  </PropertyGroup>
  
  <Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets')" />

</Project>

Project:
NFApp1.zip

Expected behaviour

No response

Screenshots

No response

Aditional context

No response

@nanoframework nanoframework locked and limited conversation to collaborators May 4, 2025
@josesimoes josesimoes converted this issue into discussion #1635 May 4, 2025

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants