I have UWP app build in VS 2017 and many project in my solution have build warning like below. How to get rid of them?
Warning "C:\Program Files (x86)\MSBuild\15.0.Net\CoreRuntime\Microsoft.Net.CoreRuntime.targets" cannot be imported again. It was already imported at "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Microsoft.Common.targets\ImportAfter\Microsoft.Net.CoreRuntime.ImportAfter.targets (17,3)". This is most likely a build authoring error. This subsequent import will be ignored. [D:\Projects\HA4IoT\Controllers\HA4IoT.Controller\HA4IoT.Service.csproj] HA4IoT.Tests
Warning "C:\Program Files (x86)\MSBuild\15.0.Net\CoreRuntime\Microsoft.Net.CoreRuntime.Settings.targets" cannot be imported again. It was already imported at "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Microsoft.Common.targets\ImportBefore\Microsoft.Net.CoreRuntime.ImportBefore.targets (17,3)". This is most likely a build authoring error. This subsequent import will be ignored. [D:\Projects\HA4IoT\DNF\HA4IoT.Extensions.Tests\HA4IoT.Extensions.Tests.csproj] HA4IoT.Controller.Dnf
Warning "C:\Users\dnf.nuget\packages\microsoft.net.native.compiler\1.6.3\tools\Microsoft.NetNative.targets" cannot be imported again. It was already imported at "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Microsoft.Common.targets\ImportAfter\Microsoft.NetNative.ImportAfter.targets (16,3)". This is most likely a build authoring error. This subsequent import will be ignored. [D:\Projects\HA4IoT\Controllers\Examples\HA4IoT.Controller.Main\HA4IoT.Controller.Main.csproj] HA4IoT.Controller.Main
How to get rid of them?
I found the work-around of this question on MSDN:
Using condition to check the existence of a unique property defined in the considering project file.
<PropertyGroup>
<TasksTargetsImported>true</TasksTargetsImported>
</PropertyGroup>
<Import Project="Tasks.targets" Condition=" '$(TasksTargetsImported)' == '' "/>
Hope this can helps.
I removed all nuget target and prop files next to the .csproj
files. This worked for me. All warnings are now gone.
Unload project or edit project solution file then check entire project file and make sure the same line is not repeated twice. In my case after I followed Web.config transformation instructions I added an extra line like the one below by mistake. You just want to make sure you have no dupes.
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\WebApplications\Microsoft.WebApplication.targets" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With