Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overwriting cs files in folder while folder is source of csproj in vs2017 RTM makes nuget restore fail on build #4846

Closed
davkean opened this issue Mar 20, 2017 · 11 comments
Labels
Functionality:Restore Resolution:NotRepro We are not able to reproduce this problem. Better steps would be helpful.
Milestone

Comments

@davkean
Copy link

davkean commented Mar 20, 2017

From @FransBouma on March 10, 2017 9:57

Hi,

I have two .net standard 1.6 class libraries in one solution, with the following contents:

AW.Model.csproj

<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netstandard1.6</TargetFramework>
    <AssemblyName>AW.Model</AssemblyName>
    <RootNamespace>AW</RootNamespace>
  </PropertyGroup>
</Project>
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netstandard1.6</TargetFramework>
    <AssemblyName>AW.Persistence</AssemblyName>
    <RootNamespace>AW</RootNamespace>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.1" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\Model\AW.Model.csproj" />
  </ItemGroup>
</Project>

They're in their own folders, Model for the first, Persistence for the second. Both folders contain .cs files, all being generated.

Now I re-generate the code files in the two folders while I have the two csproj files open in a solution (and no other projects) in vs2017 RTM. The csproj files are overwritten with the same contents (so are the other files).

When I now try to build, I get the error:
Error occurred while restoring NuGet packages: The operation failed as details for project AW.Persistence could not be loaded.

Log of MSBuild in vs2017 on rebuild with detail level 'normal'

Error occurred while restoring NuGet packages: The operation failed as details for project AW.Persistence could not be loaded.
1>------ Rebuild All started: Project: AW.Model, Configuration: Debug Any CPU ------
1>Build started 10-3-2017 10:51:46.
1>Target CoreClean:
1>  Deleting file "C:\Temp\generatortest\test1\Model\bin\Debug\netstandard1.6\AW.Model.deps.json".
1>  Deleting file "C:\Temp\generatortest\test1\Model\bin\Debug\netstandard1.6\AW.Model.dll".
1>  Deleting file "C:\Temp\generatortest\test1\Model\bin\Debug\netstandard1.6\AW.Model.pdb".
1>  Deleting file "C:\Temp\generatortest\test1\Model\obj\Debug\netstandard1.6\AW.Model.AssemblyInfo.cs".
1>  Deleting file "C:\Temp\generatortest\test1\Model\obj\Debug\netstandard1.6\AW.Model.dll".
1>  Deleting file "C:\Temp\generatortest\test1\Model\obj\Debug\netstandard1.6\AW.Model.pdb".
1>Target GenerateTargetFrameworkMonikerAttribute:
1>  Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
1>Target CoreCompile:
1>  Using shared compilation with compiler from directory: C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Roslyn
1>Target CopyFilesToOutputDirectory:
1>  Copying file from "obj\Debug\netstandard1.6\AW.Model.dll" to "bin\Debug\netstandard1.6\AW.Model.dll".
1>  AW.Model -> C:\Temp\generatortest\test1\Model\bin\Debug\netstandard1.6\AW.Model.dll
1>  Copying file from "obj\Debug\netstandard1.6\AW.Model.pdb" to "bin\Debug\netstandard1.6\AW.Model.pdb".
1>
1>Build succeeded.
1>
1>Time Elapsed 00:00:00.18
2>------ Rebuild All started: Project: AW.Persistence, Configuration: Debug Any CPU ------
2>Build started 10-3-2017 10:51:46.
2>Target CoreClean:
2>  Deleting file "C:\Temp\generatortest\test1\Persistence\bin\Debug\netstandard1.6\AW.Persistence.dll.config".
2>  Deleting file "C:\Temp\generatortest\test1\Persistence\bin\Debug\netstandard1.6\AW.Persistence.deps.json".
2>  Deleting file "C:\Temp\generatortest\test1\Persistence\bin\Debug\netstandard1.6\AW.Persistence.dll".
2>  Deleting file "C:\Temp\generatortest\test1\Persistence\bin\Debug\netstandard1.6\AW.Persistence.pdb".
2>  Deleting file "C:\Temp\generatortest\test1\Persistence\bin\Debug\netstandard1.6\AW.Model.dll".
2>  Deleting file "C:\Temp\generatortest\test1\Persistence\bin\Debug\netstandard1.6\AW.Model.pdb".
2>  Deleting file "C:\Temp\generatortest\test1\Persistence\obj\Debug\netstandard1.6\AW.Persistence.csprojResolveAssemblyReference.cache".
2>  Deleting file "C:\Temp\generatortest\test1\Persistence\obj\Debug\netstandard1.6\AW.Persistence.AssemblyInfo.cs".
2>  Deleting file "C:\Temp\generatortest\test1\Persistence\obj\Debug\netstandard1.6\AW.Persistence.dll".
2>  Deleting file "C:\Temp\generatortest\test1\Persistence\obj\Debug\netstandard1.6\AW.Persistence.pdb".
2>Target _GetProjectReferenceTargetFrameworkProperties:
2>Target ResolveProjectReferences:
2>Target GenerateTargetFrameworkMonikerAttribute:
2>  Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
2>Target CoreCompile:
2>  Using shared compilation with compiler from directory: C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Roslyn
2>Target _CopyFilesMarkedCopyLocal:
2>  Copying file from "C:\Temp\generatortest\test1\Model\bin\Debug\netstandard1.6\AW.Model.dll" to "bin\Debug\netstandard1.6\AW.Model.dll".
2>  Copying file from "C:\Temp\generatortest\test1\Model\bin\Debug\netstandard1.6\AW.Model.pdb" to "bin\Debug\netstandard1.6\AW.Model.pdb".
2>Target GetCopyToOutputDirectoryItems:
2>Target _CopyAppConfigFile:
2>  Copying file from "app.config" to "bin\Debug\netstandard1.6\AW.Persistence.dll.config".
2>Target CopyFilesToOutputDirectory:
2>  Copying file from "obj\Debug\netstandard1.6\AW.Persistence.dll" to "bin\Debug\netstandard1.6\AW.Persistence.dll".
2>  AW.Persistence -> C:\Temp\generatortest\test1\Persistence\bin\Debug\netstandard1.6\AW.Persistence.dll
2>  Copying file from "obj\Debug\netstandard1.6\AW.Persistence.pdb" to "bin\Debug\netstandard1.6\AW.Persistence.pdb".
2>
2>Build succeeded.
2>
2>Time Elapsed 00:00:00.47
========== Rebuild All: 2 succeeded, 0 failed, 0 skipped ==========

This is strange as the project is loaded properly, I can navigate the references in solution explorer as well and builds go fine. Closing / reopening VS2017 and reloading the solution file fixes the problem.

Copied from original issue: dotnet/project-system#1725

@davkean
Copy link
Author

davkean commented Mar 20, 2017

From @FransBouma on March 10, 2017 10:1

Additional info: once the sln is loaded from disk in a new vs2017 session, I can't reproduce the problem. So my guess is that this is related to some state being wrong when the sln is created (and saved), projects are added and then modified outside vs2017. Might be related to the issue I reported yesterday: #1717

@davkean
Copy link
Author

davkean commented Mar 20, 2017

This looks a lot like #4577. @emgarten @alpaix?

@davkean
Copy link
Author

davkean commented Mar 20, 2017

From @emgarten on March 10, 2017 16:46

@FransBouma the message looks scary but you can ignore it, NuGet will retry when the project details are loaded and restore everything.

@davkean yes looks like the same issue, you can probably close this one out

@davkean
Copy link
Author

davkean commented Mar 20, 2017

From @FransBouma on March 10, 2017 18:19

@emgarten

the message looks scary but you can ignore it, NuGet will retry when the project details are loaded and restore everything.

But that never happens unless the sln is re-loaded. So although it might retry, it will never actually work: only reloading the solution works. I agree though that it looks like the same issue, which IMHO all come from a bug somewhere in the initialization of the internal datastructures, as the problems are gone when the sln is reloaded, but are present when the sln is created, saved but not reloaded.

@davkean
Copy link
Author

davkean commented Mar 20, 2017

From @emgarten on March 10, 2017 18:53

So although it might retry, it will never actually work: only reloading the solution works

Even after waiting the project isn't restored?

@davkean
Copy link
Author

davkean commented Mar 20, 2017

From @FransBouma on March 10, 2017 20:45

Indeed, it stays this way. I tried numerous things for 5-10 minutes, nothing. Restarted vs2017 and reloaded the solution and that sorted it.

it's not an error that you see due to some data that's not available yet and will be gone in a few seconds or so, it's not solvable unless the solution is reloaded.

@davkean
Copy link
Author

davkean commented Mar 20, 2017

From @emgarten on March 10, 2017 21:23

@FransBouma thanks for the details, sounds like you are hitting more than just the timing issues. If it does work to reload everything then the solution/projects are likely correct. It sounds like this is just an issue with restore.

Does right clicking on the solution and selecting restore help when you hit this?

@davkean
Copy link
Author

davkean commented Mar 20, 2017

From @FransBouma on March 10, 2017 21:50

Does right clicking on the solution and selecting restore help when you hit this?

I will try that tomorrow and see what the outcome is :)

@davkean
Copy link
Author

davkean commented Mar 20, 2017

From @FransBouma on March 11, 2017 9:15

I can't reproduce it now... very strange! And not very good of course, as it might pop up later. Anyway, let's chalk this up for the restore issue already known then. I have no other explanation.

Is issue #1717 also caused by the same issue?

@emgarten
Copy link
Member

@davkean if the project isn't found even after waiting as @FransBouma described it likely means that it wasn't nominated and NuGet cannot find it for that reason.

@emgarten emgarten added the Resolution:NotRepro We are not able to reproduce this problem. Better steps would be helpful. label Oct 17, 2017
@emgarten emgarten added this to the 4.5 milestone Oct 17, 2017
@emgarten
Copy link
Member

Closing based on the previous conversation, if you are still hitting this please provide additional repro steps. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Functionality:Restore Resolution:NotRepro We are not able to reproduce this problem. Better steps would be helpful.
Projects
None yet
Development

No branches or pull requests

3 participants