try-convert icon indicating copy to clipboard operation
try-convert copied to clipboard

If NuGet Targets are pressent, then the project can't be converted

Open Lohnegrim opened this issue 6 years ago • 5 comments

Hi, I noticed, that when a import to NuGet.targets is present, (as was added by EF6.3 install), then the project conversion fails with error 'This project has custom imports in a manner that's not supported.' The effected line is: <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" /> Seems like packages with a path in '' are ignored, maybe the path '\.nuget' should also be ignored?

Lohnegrim avatar Nov 07 '19 12:11 Lohnegrim

@Lohnegrim can you point me to a sample project with this targets import? I am not aware of a situation that will cause Entity Framework 6.3 to add a Nuget.targets file. There are samples out there that show how to write a custom targets file that manipulates nuget but our belief was that if you were in this situation you had customized your build which would make it very unlikely the conversion would succeed.

jmarolf avatar Nov 07 '19 22:11 jmarolf

@jmarolf as I just read in https://docs.microsoft.com/en-us/nuget/consume-packages/package-restore#migrate-to-automatic-package-restore-visual-studio the nuget.targets was added by using the deprecated MSBuild-integrated package restore, so it may be better for me to remove it. Anyway it's an old feature from VS/NuGet, and in my case it was by chance that it was added with EF 6.3

Lohnegrim avatar Nov 08 '19 10:11 Lohnegrim

@Lohnegrim I believe removing it would probably be the best course of action. I'm not sure we can have this tool support things that older (often deprecated) VS tooling would do to a project. Though in this case if removing the file causes the conversion to work, a quick patch could probably be made with this as a well-known import that we just remove.

cartermp avatar Nov 08 '19 14:11 cartermp

The issue is we have no way of knowing if this target does custom things in your build other than restore nuget. We could emit a better message pointing to these docs and suggesting the user delete the folder and the imports, but assuming they are safe to remove seems like a recipe for disaster.

jmarolf avatar Nov 08 '19 19:11 jmarolf

I have to remove the below line to fix the error in a test project.

<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />

sundeepyama avatar Dec 01 '20 20:12 sundeepyama