1

I have .Net Core 3.1 console application which is referring to a class library project FxCore which is added as a reference. class library csproj has <TargetFrameworks>net45;net451;net452;net46;net461;net462;net47;net471;net472</TargetFrameworks> I have tried changing it to <TargetFrameworks>net45;</TargetFrameworks>, but still getting the same error.

I am getting the below error., I have tried clean -> ReBuild, Reopen the visual studio 2019 (version 16.5.2)

1>------ Build started: Project: FxCore, Configuration: Debug Any CPU ------ 1>J:\Test\core\fx-core\FxCore.csproj(3,3): warning MSB4011: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Microsoft.Common.props" cannot be imported again. It was already imported at "C:\Program Files\dotnet\sdk\3.1.201\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.props (40,3)". This is most likely a build authoring error. This subsequent import will be ignored. 1>C:\Program Files\dotnet\sdk\3.1.201\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.targets(37,3): warning MSB4011: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Microsoft.CSharp.targets" cannot be imported again. It was already imported at "J:\Test\core\fx-core\FxCore.csproj (120,3)". This is most likely a build authoring error. This subsequent import will be ignored. 1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2081,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "FXEntity, Version=1.0.1.12, Culture=neutral, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. 1>FxCore -> J:\Test\core\fx-core\bin\Debug\FxCore.dll 1>J:\Test\core\fx-core\FxCore.csproj(3,3): warning MSB4011: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Microsoft.Common.props" cannot be imported again. It was already imported at "C:\Program Files\dotnet\sdk\3.1.201\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.props (40,3)". This is most likely a build authoring error. This subsequent import will be ignored. 1>C:\Program Files\dotnet\sdk\3.1.201\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.targets(37,3): warning MSB4011: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Microsoft.CSharp.targets" cannot be imported again. It was already imported at "J:\Test\core\fx-core\FxCore.csproj (120,3)". This is most likely a build authoring error. This subsequent import will be ignored. 1>J:\Test\core\fx-core\FxCore.csproj(3,3): warning MSB4011: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Microsoft.Common.props" cannot be imported again. It was already imported at "C:\Program Files\dotnet\sdk\3.1.201\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.props (40,3)". This is most likely a build authoring error. This subsequent import will be ignored. 1>C:\Program Files\dotnet\sdk\3.1.201\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.targets(37,3): warning MSB4011: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Microsoft.CSharp.targets" cannot be imported again. It was already imported at "J:\Test\core\fx-core\FxCore.csproj (120,3)". This is most likely a build authoring error. This subsequent import will be ignored. 1>J:\Test\core\fx-core\FxCore.csproj : warning NU1603: FxCore depends on Microsoft.Practices.ServiceLocation (>= 1.3.0) but Microsoft.Practices.ServiceLocation 1.3.0 was not found. An approximate best match of Microsoft.Practices.ServiceLocation 1.4.11 was resolved. 1>Done building project "FxCore.csproj". 1>Done building project "FxCore.csproj". 2>------ Build started: Project: CoreConsoleApp, Configuration: Debug Any CPU ------ 2>J:\Test\core\fx-core\FxCore.csproj(3,3): warning MSB4011: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Microsoft.Common.props" cannot be imported again. It was already imported at "C:\Program Files\dotnet\sdk\3.1.201\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.props (40,3)". This is most likely a build authoring error. This subsequent import will be ignored. 2>C:\Program Files\dotnet\sdk\3.1.201\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.targets(37,3): warning MSB4011: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Microsoft.CSharp.targets" cannot be imported again. It was already imported at "J:\Test\core\fx-core\FxCore.csproj (120,3)". This is most likely a build authoring error. This subsequent import will be ignored. 2>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(1655,5): warning NU1702: ProjectReference 'J:\Test\core\fx-core\FxCore.csproj' was resolved using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v3.1'. This project may not be fully compatible with your project. 2>J:\Test\core\CoreConsoleApp\Program.cs(2,7,2,9): error CS0246: The type or namespace name 'FX' could not be found (are you missing a using directive or an assembly reference?) 2>J:\Test\core\CoreConsoleApp\Program.cs(7,24,7,32): error CS0246: The type or namespace name 'FxCommon' could not be found (are you missing a using directive or an assembly reference?) 2>Done building project "CoreConsoleApp.csproj" -- FAILED. ========== Build: 1 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

But in the Program.cs I am able to use the code, IntelliSense not showing any error.

using System;
using FX.Core;
namespace CoreConsoleApp
{
    class Program
    {
        private static FxCommon _fxCommon = new FxCommon();
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            _fxCommon.Logger.LogWrite("hello");
        }
    }
}

I am not able to run the console application due to this, please help.

2
  • So what is your question? Commented Jul 8, 2020 at 7:00
  • how to solve this issue? and make the solution build Commented Jul 8, 2020 at 7:00

2 Answers 2

3

.NET Core doesn't consume .NET Framework (net###) targets; it can consume netstandard* and netcoreapp*.

So; your FxCore is going to need to target/multi-target one of .NET Standard or .NET Core.

In terms of choice of what to target/multi-target:

  1. target netstandard* - if you don't need anything framework-specific in the implementation
  2. multi-target netcoreapp* and netstandard* - if you want to use netcoreapp* features when they are available, or use a down-level common implementation otherwise
  3. multi-target netcoreapp* and net### - if the implementations are completely platform specific and no common implementation is possible

(where * / ### is your choice of versions - probably netstandard2.1, netcoreapp3.1 and net472/net48 at the current time)

Sign up to request clarification or add additional context in comments.

1 Comment

I have solved the issue by removing a few lines from csproj file,I have mentioned that in my answer. please let me know if its wrong wat.
0

I have solved the issue by removing the below lines from the class library csproj file.

  <PropertyGroup>
    <TargetFrameworks>net45;net451;net452;net46;net461;net462;net47;net471;net472</TargetFrameworks>
  </PropertyGroup>
  <PropertyGroup>

9 Comments

that's odd; you are required to specify a target framework or frameworks, otherwise you get a NETSDK1013 build error - is there another <TargetFramework> / <TargetFrameworks> element coming from somewhere else in the tree?
@MarcGravell in csproj file there is another line <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
There's no need to add all possible frameworks though. Why was this added in the first place? Was there another bug, and this line was added to silence it?
It was already there, I just cloned the project today @PanagiotisKanavos
nope, checking locally, adding <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> does nothing useful to prevent NETSDK1013. There's something more involved in your build.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.