project-system: "Loop dependent files" error when loading project in latest .csproj tooling

When loading the repro here on latest bits: https://github.com/MiniProfiler/dotnet/tree/6e2ccc233da4f9d8614a57573857c885292e1881

You’ll get an on-load exception for the Samples.Mvc5 project. Error:

Microsoft.VisualStudio.ProjectSystem.ProjectException: Loop dependent files found inside “y”.

Content of .csproj:

<Project Sdk="Microsoft.NET.Sdk.Web" ToolsVersion="15.0">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <OutputType>Library</OutputType>
    <RootNamespace>Samples.Mvc5</RootNamespace>
    <AssemblyName>Samples.Mvc5</AssemblyName>
    <TargetFramework>net462</TargetFramework>
    <UseIISExpress>true</UseIISExpress>
    <OutputPath>bin\</OutputPath>
  </PropertyGroup>
  <ItemGroup>
    <ProjectReference Include="..\..\src\MiniProfiler.EntityFramework\MiniProfiler.EntityFramework.csproj" />
    <ProjectReference Include="..\..\src\MiniProfiler.Mvc\MiniProfiler.Mvc.csproj" />
    <ProjectReference Include="..\..\src\MiniProfiler.Providers.SqlServer\MiniProfiler.Providers.SqlServer.csproj" />
    <ProjectReference Include="..\..\src\MiniProfiler.Shared\MiniProfiler.Shared.csproj" />
    <ProjectReference Include="..\..\src\MiniProfiler\MiniProfiler.csproj" />
    <PackageReference Include="EntityFramework.SqlServerCompact" Version="6.1.3" />
    <PackageReference Include="Microsoft.AspNet.Mvc" Version="5.2.3" />
    <PackageReference Include="Microsoft.AspNet.Web.Optimization" Version="1.1.3" />
    <PackageReference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" Version="1.0.2.0" />
    <PackageReference Include="System.Data.SQLite" Version="1.0.103" />
    <PackageReference Include="System.Data.SQLite.EF6" Version="1.0.103" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System" />
    <Reference Include="System.Data" />
    <Reference Include="System.Drawing" />
    <Reference Include="System.ComponentModel.DataAnnotations" />
    <Reference Include="System.Configuration" />
    <Reference Include="System.Core" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="System.Net.Http" />
    <Reference Include="System.Net.Http.WebRequest" />
    <Reference Include="System.ServiceModel" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Web" />
    <Reference Include="System.Web.Abstractions" />
    <Reference Include="System.Web.ApplicationServices" />
    <Reference Include="System.Web.DynamicData" />
    <Reference Include="System.Web.Entity" />
    <Reference Include="System.Web.Extensions" />
    <Reference Include="System.Web.Routing" />
    <Reference Include="System.Web.Services" />
    <Reference Include="System.Xml" />
  </ItemGroup>
  <ItemGroup>
    <None Include="_bin_deployableAssemblies\**\*" />
    <Content Include="App_Data\SampleEfModelFirst.mdf" />
    <Content Include="App_Data\SampleEfModelFirst_log.ldf" />
    <Content Include="Content\**\*" />
    <EntityDeploy Include="EfModelFirst\EfModelFirstContext.edmx">
      <Generator>EntityModelCodeGenerator</Generator>
      <LastGenOutput>EfModelFirstContext1.Designer.cs</LastGenOutput>
    </EntityDeploy>
    <Content Include="EfModelFirst\EfModelFirstContext.Context.tt">
      <Generator>TextTemplatingFileGenerator</Generator>
      <DependentUpon>EfModelFirstContext.edmx</DependentUpon>
      <LastGenOutput>EfModelFirstContext.Context.cs</LastGenOutput>
    </Content>
    <Content Include="EfModelFirst\EfModelFirstContext.edmx.diagram">
      <DependentUpon>EfModelFirstContext.edmx</DependentUpon>
    </Content>
    <Content Include="EfModelFirst\EfModelFirstContext.tt">
      <Generator>TextTemplatingFileGenerator</Generator>
      <DependentUpon>EfModelFirstContext.edmx</DependentUpon>
      <LastGenOutput>EfModelFirstContext.cs</LastGenOutput>
    </Content>
    <Content Include="Scripts\**\*" />
    <Content Include="favicon.ico" />
    <Content Include="Global.asax" />
  </ItemGroup>
  <ItemGroup>
    <Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
  </ItemGroup>
  <Target Name="MvcBuildViews" AfterTargets="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
    <AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" />
  </Target>
  <ProjectExtensions>
    <VisualStudio>
      <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
        <WebProjectProperties>
          <UseIIS>True</UseIIS>
          <AutoAssignPort>True</AutoAssignPort>
          <DevelopmentServerPort>51485</DevelopmentServerPort>
          <DevelopmentServerVPath>/</DevelopmentServerVPath>
          <IISUrl>http://localhost:51485/</IISUrl>
          <NTLMAuthentication>False</NTLMAuthentication>
          <UseCustomServer>False</UseCustomServer>
          <CustomServerUrl />
          <SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
        </WebProjectProperties>
      </FlavorProperties>
    </VisualStudio>
  </ProjectExtensions>
  <PropertyGroup>
    <!-- Working around https://github.com/dotnet/sdk/issues/550 -->
    <PostBuildEvent>
    start xcopy /s /y "$(MSBuildProjectDirectory)\bin\net462\*.*" "$(MSBuildProjectDirectory)\bin"
    </PostBuildEvent>
  </PropertyGroup>
</Project>

(don’t ask about the copy…that’s another issue)

The error is:

=====================
1/16/17 8:29:42 AM
Recoverable
System.AggregateException: One or more errors occurred. ---> Microsoft.VisualStudio.ProjectSystem.ProjectException: Loop dependent files found inside "y".
   at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.TreeService.EnsureNotFaultedTree(IProjectVersionedValue`1 appliedValue)
   at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.TreeService.<PublishAnyNonLoadingTreeAsync>d__68.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.ProjectNode.<>c__DisplayClass636_0.<<ParseCanonicalName>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.Threading.JoinableTask.CompleteOnCurrentThread()
   at Microsoft.VisualStudio.Threading.JoinableTask`1.CompleteOnCurrentThread()
   at Microsoft.VisualStudio.Threading.JoinableTaskFactory.Run[T](Func`1 asyncMethod, JoinableTaskCreationOptions creationOptions)
   at Microsoft.VisualStudio.ProjectSystem.ProjectMultiThreadedService.ExecuteSynchronously[T](Func`1 asyncAction)
   at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.ProjectNode.<>c__DisplayClass554_0.<HrInvoke>b__0()
   at Microsoft.VisualStudio.ProjectSystem.VS.HResult.Invoke(Func`1 action, IServiceProvider vsShellServiceProvider, IProjectFaultHandlerService projectFaultHandlerService, UnconfiguredProject project)
   --- End of inner exception stack trace ---
---> (Inner Exception #0) Microsoft.VisualStudio.ProjectSystem.ProjectException: Loop dependent files found inside "EfModelFirst".
   at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.TreeService.EnsureNotFaultedTree(IProjectVersionedValue`1 appliedValue)
   at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.TreeService.<PublishAnyNonLoadingTreeAsync>d__68.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.ProjectNode.<>c__DisplayClass636_0.<<ParseCanonicalName>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.Threading.JoinableTask.CompleteOnCurrentThread()
   at Microsoft.VisualStudio.Threading.JoinableTask`1.CompleteOnCurrentThread()
   at Microsoft.VisualStudio.Threading.JoinableTaskFactory.Run[T](Func`1 asyncMethod, JoinableTaskCreationOptions creationOptions)
   at Microsoft.VisualStudio.ProjectSystem.ProjectMultiThreadedService.ExecuteSynchronously[T](Func`1 asyncAction)
   at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.ProjectNode.<>c__DisplayClass554_0.<HrInvoke>b__0()
   at Microsoft.VisualStudio.ProjectSystem.VS.HResult.Invoke(Func`1 action, IServiceProvider vsShellServiceProvider, IProjectFaultHandlerService projectFaultHandlerService, UnconfiguredProject project)<---
===================

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 18 (14 by maintainers)

Commits related to this issue

Most upvoted comments

TL;DR: In a .NET Core website nesting of .ts files below .html is default behavior and manually nesting the opposite way (.html below .ts) appears to get in the way and cause the loop error. Deleting a file will also delete any nested files.

Hopefully my experience helps someone. I started with a full framework WebApi application with Angular 2 in an app folder. I had manually nested Angular 2 component templates (.html) under their respective component (.ts) in Solution Explorer using an extension.

I opened in VS2017 RTM and created a new .NET Core website. I tried copying the files in app to the new website using Solution Explorer and ran into the error @StingyJack and @NickCraver posted. Reopening the project/solution showed the same error again. Clearing the files in the target folder didn’t fix it. I noticed the .csproj was maintaining <DependentUpon> for the files I had tried copying but no longer existed. I cleared any references to the app folder from the .csproj and copied it again using Windows Explorer. After reopening the solution it all loaded correctly. .csproj no longer had any references to the app folder but the .ts files were nested under .html.

If you only have a .ts file it will be at the top level. I then tested adding a .html file and it auto-nested the existing .ts file below the new .html file. I tried deleting the new .html file and it also deleted the nested .ts file even though the prompt only asked if you wanted to delete .html. I’m not sure at this point how to delete only the top file.

Just an update from my end. I ran into this today. I had a folder under the wwwroot folder called “Temp”. I never got an issue until I turned off “ReSharper Ultimate 2017.3.2” extension. Then the issue happened. Editing the csproj file and removed the line <Folder Include="wwwroot\temp\" /> and the project would load.