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

Build Accelertion - appsettings.json edits not picked up when debugging #8928

Closed
AndyStevenson7 opened this issue Mar 21, 2023 · 10 comments
Closed
Labels
Area-External Owned by another feature area and not this repo. Likely be closed in lieu of issue against it. Discussion/Question A discussion or question about the project that will not be treated as a bug or feature request. Feature-Up-to-date Build up-to-date check that avoids shelling out to MSBuild unless necessary. Resolution-External The bug is owned by a feature team outside of this repository.

Comments

@AndyStevenson7
Copy link

AndyStevenson7 commented Mar 21, 2023

Visual Studio Version

17.5.2

Summary

With Build Acceleration enabled, when I edit a config setting in appsettings.json and run in debug, the compiler does not pick up the change, unless I first run a build. The default Build Action on a settings file is 'None'. If I set this to 'Embedded Resource' then it seems to work.

Steps to Reproduce

  1. Add a new settings file to a VS project
  2. Compile and run the project in debug
  3. Edit a setting and run debug again. The setting change is not picked up.

Expected Behavior

Edits to a setting file should be picked up by the compiler

Actual Behavior

The setting change is not picked up by the compiler

User Impact

Any new projects with a settings file added, that defaults to Build Action: None may cause confusion when testing in debug mode, for example, changing connections to databases, API endpoints etc.

@AndyStevenson7
Copy link
Author

AndyStevenson7 commented Mar 21, 2023

Added a test project on Github to reproduce this issue: https://github.com/AndyStevenson7/Test_BuildAcceleration_ConfigChange

@drewnoakes
Copy link
Member

Hi @AndyStevenson7. Thanks for the detailed report, and for the repro repo!

When I clone your repo and follow the above steps, I see that a build is in fact triggered:

Build started...
1>FastUpToDate: Comparing timestamps of inputs and outputs: (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate:     Adding UpToDateCheckBuilt outputs: (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate:         C:\repo\Test_BuildAcceleration_ConfigChange\bin\Debug\net6.0\Test_BuildAcceleration_ConfigChange.dll (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate:         C:\repo\Test_BuildAcceleration_ConfigChange\obj\Debug\net6.0\Test_BuildAcceleration_ConfigChange.dll (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate:         C:\repo\Test_BuildAcceleration_ConfigChange\obj\Debug\net6.0\Test_BuildAcceleration_ConfigChange.pdb (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate:         C:\repo\Test_BuildAcceleration_ConfigChange\bin\Debug\net6.0\Test_BuildAcceleration_ConfigChange.pdb (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate:     Adding project file inputs: (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate:         C:\repo\Test_BuildAcceleration_ConfigChange\Test_BuildAcceleration_ConfigChange.csproj (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate:     Adding newest import input: (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate:         C:\repo\Test_BuildAcceleration_ConfigChange\obj\Test_BuildAcceleration_ConfigChange.csproj.nuget.g.targets (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate:     Adding Compile inputs: (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate:         C:\repo\Test_BuildAcceleration_ConfigChange\Program.cs (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate:     No inputs are newer than earliest output 'C:\repo\Test_BuildAcceleration_ConfigChange\obj\Debug\net6.0\Test_BuildAcceleration_ConfigChange.pdb' (2023-03-22 11:46:57.657). Newest input is 'C:\repo\Test_BuildAcceleration_ConfigChange\obj\Test_BuildAcceleration_ConfigChange.csproj.nuget.g.targets' (2023-03-22 11:46:34.192). (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate: Checking items to copy to the output directory: (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate:     Checking copy items from project 'C:\repo\Test_BuildAcceleration_ConfigChange\Test_BuildAcceleration_ConfigChange.csproj': (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate:         Checking PreserveNewest item (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate:             Source      2023-03-22 11:46:57.711: 'C:\repo\Test_BuildAcceleration_ConfigChange\obj\Debug\net6.0\apphost.exe' (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate:             Destination 2023-03-22 11:46:57.711: 'C:\repo\Test_BuildAcceleration_ConfigChange\bin\Debug\net6.0\Test_BuildAcceleration_ConfigChange.exe' (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate:         Checking Always item (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate:             Source      2023-03-22 11:47:44.646: 'C:\repo\Test_BuildAcceleration_ConfigChange\appsettings.json' (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate:             Destination 2023-03-22 11:45:55.708: 'C:\repo\Test_BuildAcceleration_ConfigChange\bin\Debug\net6.0\appsettings.json' (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate: Item with CopyToOutputDirectory="Always" source ('C:\repo\Test_BuildAcceleration_ConfigChange\appsettings.json' 2023-03-22 11:47:44.646, 68 bytes) differs from destination ('C:\repo\Test_BuildAcceleration_ConfigChange\bin\Debug\net6.0\appsettings.json' 2023-03-22 11:45:55.708, 66 bytes), not up-to-date. (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate: This project appears to be a candidate for build acceleration. To opt in, set the 'AccelerateBuildsInVisualStudio' MSBuild property to 'true'. See https://aka.ms/vs-build-acceleration. (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate: Up-to-date check completed in 3.2 ms (Test_BuildAcceleration_ConfigChange)
1>------ Build started: Project: Test_BuildAcceleration_ConfigChange, Configuration: Debug Any CPU ------
1>C:\Program Files\dotnet\sdk\7.0.300-preview.23165.23\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(287,5): message NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy
1>Test_BuildAcceleration_ConfigChange -> C:\repo\Test_BuildAcceleration_ConfigChange\bin\Debug\net6.0\Test_BuildAcceleration_ConfigChange.dll
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Build started at 11:47 AM and took 00.478 seconds ==========

The key line is:

Item with CopyToOutputDirectory="Always" source ('C:\repo\Test_BuildAcceleration_ConfigChange\appsettings.json' 2023-03-22 11:47:44.646, 68 bytes) differs from destination ('C:\repo\Test_BuildAcceleration_ConfigChange\bin\Debug\net6.0\appsettings.json' 2023-03-22 11:45:55.708, 66 bytes), not up-to-date.

Note that the project is then actually built. Further, the appsettings.json file is copied to the output folder as expected.

Note that your project does not actually enable Build Acceleration. When I enable it, I see that acceleration occurs as expected.

Build started...
1>FastUpToDate: Comparing timestamps of inputs and outputs: (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate:     Adding UpToDateCheckBuilt outputs: (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate:         C:\repo\Test_BuildAcceleration_ConfigChange\bin\Debug\net6.0\Test_BuildAcceleration_ConfigChange.dll (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate:         C:\repo\Test_BuildAcceleration_ConfigChange\obj\Debug\net6.0\Test_BuildAcceleration_ConfigChange.dll (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate:         C:\repo\Test_BuildAcceleration_ConfigChange\obj\Debug\net6.0\Test_BuildAcceleration_ConfigChange.pdb (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate:         C:\repo\Test_BuildAcceleration_ConfigChange\bin\Debug\net6.0\Test_BuildAcceleration_ConfigChange.pdb (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate:     Adding project file inputs: (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate:         C:\repo\Test_BuildAcceleration_ConfigChange\Test_BuildAcceleration_ConfigChange.csproj (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate:     Adding newest import input: (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate:         C:\repo\Test_BuildAcceleration_ConfigChange\Test_BuildAcceleration_ConfigChange.csproj (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate:     Adding Compile inputs: (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate:         C:\repo\Test_BuildAcceleration_ConfigChange\Program.cs (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate:     No inputs are newer than earliest output 'C:\repo\Test_BuildAcceleration_ConfigChange\obj\Debug\net6.0\Test_BuildAcceleration_ConfigChange.pdb' (2023-03-22 11:51:24.508). Newest input is 'C:\repo\Test_BuildAcceleration_ConfigChange\Test_BuildAcceleration_ConfigChange.csproj' (2023-03-22 11:51:23.817). (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate: Checking items to copy to the output directory: (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate:     Checking copy items from project 'C:\repo\Test_BuildAcceleration_ConfigChange\Test_BuildAcceleration_ConfigChange.csproj': (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate:         Checking PreserveNewest item (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate:             Source      2023-03-22 11:51:24.526: 'C:\repo\Test_BuildAcceleration_ConfigChange\obj\Debug\net6.0\apphost.exe' (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate:             Destination 2023-03-22 11:51:24.526: 'C:\repo\Test_BuildAcceleration_ConfigChange\bin\Debug\net6.0\Test_BuildAcceleration_ConfigChange.exe' (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate:         Checking Always item (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate:             Source      2023-03-22 11:51:28.787: 'C:\repo\Test_BuildAcceleration_ConfigChange\appsettings.json' (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate:             Destination 2023-03-22 11:50:51.171: 'C:\repo\Test_BuildAcceleration_ConfigChange\bin\Debug\net6.0\appsettings.json' (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate:             Remembering the need to copy file 'C:\repo\Test_BuildAcceleration_ConfigChange\appsettings.json' to 'C:\repo\Test_BuildAcceleration_ConfigChange\bin\Debug\net6.0\appsettings.json'. (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate: Copying 1 files to accelerate build (https://aka.ms/vs-build-acceleration): (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate:     From 'C:\repo\Test_BuildAcceleration_ConfigChange\appsettings.json' to 'C:\repo\Test_BuildAcceleration_ConfigChange\bin\Debug\net6.0\appsettings.json'. (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate: Build acceleration copied 1 files. (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate: Project is up-to-date. (Test_BuildAcceleration_ConfigChange)
1>FastUpToDate: Up-to-date check completed in 6.6 ms (Test_BuildAcceleration_ConfigChange)
========== Build: 0 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
========== Build started at 11:51 AM and took 00.067 seconds ==========
Visual Studio accelerated 1 project(s), copying 1 file(s). See https://aka.ms/vs-build-acceleration.

Could you please enable verbose logging for the up-to-date check and share your logs here?

image

@drewnoakes
Copy link
Member

Note that your project actually uses a Content type for appsettings.json, not a None type:

  <ItemGroup>
    <None Remove="appsettings.json" />
  </ItemGroup>

  <ItemGroup>
    <Content Include="appsettings.json">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
  </ItemGroup>

Though even if I have it as a None item I see the correct behaviour, both with and without Build Acceleration.

  <ItemGroup>
    <None Update="appsettings.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
  </ItemGroup>

@drewnoakes drewnoakes added Discussion/Question A discussion or question about the project that will not be treated as a bug or feature request. Feature-Up-to-date Build up-to-date check that avoids shelling out to MSBuild unless necessary. labels Mar 22, 2023
@drewnoakes
Copy link
Member

@AndyStevenson7 I think the problem you're experiencing is actually elsewhere. It seems there's a bug where using F5 to build completely skips any kind of up-to-date check. You can see, for example, there's no build summary in the Output window as there normally would be. I've reported this internally.

If you build the project before pressing F5, does the project work correctly for you? Obviously this is not idea, but it would confirm that you're hitting the same issue.

@drewnoakes
Copy link
Member

Here's a feedback ticket for the issue you're seeing. I'll close this as a duplicate of that ticket (if you believe it's not a dupe, let me know and we can re-open this, but I'm quite sure it's what you're seeing.)

https://developercommunity.visualstudio.com/t/Copy-if-newer---Issue-when-only-non-sour/10308822

You might like to vote on that ticket to help it gain priority.

@drewnoakes drewnoakes closed this as not planned Won't fix, can't repro, duplicate, stale Mar 22, 2023
@drewnoakes drewnoakes added Area-External Owned by another feature area and not this repo. Likely be closed in lieu of issue against it. Resolution-External The bug is owned by a feature team outside of this repository. labels Mar 22, 2023
@AndyStevenson7
Copy link
Author

Hey @drewnoakes
Thanks for your investigations! Sorry for the slow reply, been a busy week.

My issue does look like a duplicate of the one you listed above (10308822), so I'll track the progress on it.

Many thanks
Andrew

@AndyStevenson7
Copy link
Author

To answer your question: if I build before pressing F5 it works as expected. The issue seems to be that a resource marked with BuildAction: None does not trigger a build when you F5, but if it's BuildAction: Embedded Resource then it works. Need to run a few tests and check the build logs.

@drewnoakes
Copy link
Member

Thank you for confirming. That does sound like the same bug. It's currently with another team, so that feedback ticket is the best place to track it.

@drewnoakes
Copy link
Member

@AndyStevenson7, following up on this, in the end we decided to make a workaround in this repo to address this bug.

Fixed in #9130 which should make 17.7 preview 3. Thanks again for filing this, and for your patience.

@AndyStevenson7
Copy link
Author

@drewnoakes thanks for the feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-External Owned by another feature area and not this repo. Likely be closed in lieu of issue against it. Discussion/Question A discussion or question about the project that will not be treated as a bug or feature request. Feature-Up-to-date Build up-to-date check that avoids shelling out to MSBuild unless necessary. Resolution-External The bug is owned by a feature team outside of this repository.
Projects
None yet
Development

No branches or pull requests

2 participants