2

PathTooLongException with _GenerateBindingRedirectsIntermediateAppConfig

 4 years ago
source link: https://github.com/dotnet/msbuild/issues/1786
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

PathTooLongException with _GenerateBindingRedirectsIntermediateAppConfig #1786

Closed

bricelam opened this issue on Mar 3, 2017 · 8 comments

Comments

Member

bricelam commented on Mar 3, 2017

We just hit a PathTooLongException on EF because this variable was producing the following path.

C:\Projects\EntityFramework\test\Microsoft.EntityFrameworkCore.SqlServer.Design.FunctionalTests\obj\Debug\netcoreapp1.1\Microsoft.EntityFrameworkCore.SqlServer.Design.FunctionalTests.csproj.Microsoft.EntityFrameworkCore.SqlServer.Design.FunctionalTests.dll.config

That filename seems rather excessive. Does it really need both $(MSBuildProjectFile) and $(TargetFileName) in there?

Contributor

rainersigwald commented on Mar 4, 2017

It doesn't seem like it at first glance.

I've been spelunking through history trying to figure out why it's this way, and it seems to have been introduced in dev12 with GenerateBindingRedirects. I suspect it was named this way as a compromise between

  • The standard $(IntermediateOutputPath)$(MSBuildProjectFile).{filename} pattern for project-singleton caches and
  • The standard app-config naming convention of $(TargetFileName).config

This does cause duplication in the standard case, and having a very long project name that's the same as the assembly name is not uncommon.

I think we could change this variable to $(IntermediateOutputPath)$(MSBuildProjectFile).app.config. Anyone have an idea why not?

(Obligatory "the real problem is #53 and then don't worry about this". Obligatory "but we live in the current world".)

Contributor

pranavkm commented on Mar 24, 2017

Noticed another variant of this - the CLI happily creates the intermediate file with a path too long, but doesn't copy it to the output directory. Desktop .NET returns false for file existence, maybe that has something to do with it.

Member

tmat commented on Jun 29, 2017

Why not $(IntermediateOutputPath)$(TargetFileName).config?

Contributor

rainersigwald commented on Jun 29, 2017

That seems like a reasonable option, too. I don't know whether exe-name or project-name is a "more unique" key for those who take the painful road of sharing an obj directory.

Member

tmat commented on Jun 29, 2017

If the .exe/.dll name wasn't unique the assembly would collide in the shared obj directory.

Workaround:

<Target Name="WorkaroundAppConfigPathTooLong"
          BeforeTargets="GenerateBindingRedirects">
    <PropertyGroup>
      <_GenerateBindingRedirectsIntermediateAppConfig>$(IntermediateOutputPath)$(TargetFileName).config</_GenerateBindingRedirectsIntermediateAppConfig>
    </PropertyGroup>
  </Target>

produces:

image

Contributor

pranavkm commented on Jun 29, 2017

@tmat for the time being, we've resorted to shortening our project names. Seems less hacky than changing an internal property.

I'm currently facing the same problem, and blogged about it here - mostly in terms of how I diagnosed it.

This does seem pretty unnecessarily long at the moment.

Member

nguerrera commented on Aug 30, 2017

Tomas' rationale is right. If TargetFileName weren't unique in obj then you'd already be hosed. Can we go with it and get this fixed in 15.5?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Assignees

No one assigned

Labels
None yet
Projects

None yet

Milestone

MSBuild 15.5

Linked pull requests

Successfully merging a pull request may close this issue.

None yet

7 participants

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK