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

Created on 16 Jan 2017  路  17Comments  路  Source: dotnet/project-system

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)<---
===================
Area-External-CPS Triage-Approved

Most helpful comment

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.

All 17 comments

Tracked here

Is there any progress on this? It's a crash on startup, that's a fairly severe thing to leave out of 1.0.

@NickCraver Are you blocked on this? The cause is because we're getting conflicting requirements from a service in the project and your project. If you remove the DependentUpon under EfModelFirstContext.tt - the crash will no longer occur.

We're at the point for 1.0 where we're focusing on crashes and hangs without workarounds.

This happens to me when I open the solution. If I close the solution and delete the files in the folder its complaining about, I can load the solution. Easy fix but caused me a brief panic and could very well be my own doing but I figured I would share the resolution here if anyone could benefit.

Log file attached. Repro source at https://github.com/StingyJack/Mermaider, commit 38822454fd9a2f7ba487f8a6a37c94250eddf8df

image
VsProjectFault_bfa6d23b-5250-4928-a8e9-ceee4b0dec09.failure.txt

Thanks @StingyJack for the additional info.

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.

I ran into a simliar issue today. Mine was including a folder that didn't actually exist and another that was empty in the Deleted them and all was well.

I ran into this as well.

It would be nice if CPS could have it's default logic, but that would fall out if the user manually specified a different DependentUpon that caused a circular dependency (and then it would only fail if the user themselves manually specified a circular DependentUpon).

I could see how that might be difficult to support however.

I imagine this would also impact the WPF *.xaml and *.cs nesting for .NET Core 3.0

@tannergooding Can you paste the project file that triggered the fault? Agree we should do something around this.

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <Compile Update="Resources.cs" DependentUpon="Resources.resx" />
  </ItemGroup>

</Project>

Thanks. I agree we should handle this and avoid faulting in this situation. This is implementation bleeding out - nesting is provided by a set of extensions, one of which is the project file. We usually fault when there's bugs in extensions, but clearly above is a normal user construct.

@tannergooding as a workaround, if it works for you, is to rename the .cs file to Resources.Designer.cs and then the in built nested file system will leave it alone, so the DependentUpon attribute will take affect.

@davkean , is there any plans on fixing this ? Right now this is blocking us from moving to 2019 on our project. Everything works fine in 2017, Its impossible for us to perform the workaround @davidwengier suggested.

  1. We have too many such files
  2. We have the following relationship: resx => t4 template (tt file) => generated cs. The t4 template references a third party include file that controls the output filename and we cannot change that - thus the cs filename will always be named as the resx file.

Just to provide a temporary workaround. You can add

<EmbeddedResource Update="Resources.resx" DependentUpon="-" />

to suppress the dependency rule extender to collapse it under another file. Or you can apply similar thing to any file in your project to break up the loop.

@swesonga not sure if this is targeted for 16.8, feel free to move it as appropriate.

Was this page helpful?
0 / 5 - 0 ratings