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

Copy static assets during BeforeBuild target to fix Visual Studio "rebuild" failures #11216

Merged
merged 1 commit into from
Sep 30, 2021

Conversation

OzoneNZ
Copy link
Contributor

@OzoneNZ OzoneNZ commented Sep 29, 2021

Description

Fixes issue #11215 when using Rebuild option in Visual Studio/msbuild where every second rebuild would fail due to missing static asset files

Fixes #10760
Fixes #11215

PZPpEVXscy

msbuild output prior to this change:

1>Target _CopyOutOfDateSourceItemsToOutputDirectoryAlways:
1>  Microsoft.Common.CurrentVersion.targets(4996,5): error MSB3030: Could not copy the file "C:\Umbraco9Test\umbraco\config\appsettings-schema.json" because it was not found.
1>  Microsoft.Common.CurrentVersion.targets(4996,5): error MSB3030: Could not copy the file "C:\Umbraco9Test\umbraco\config\lang\cy.xml" because it was not found.
1>  Microsoft.Common.CurrentVersion.targets(4996,5): error MSB3030: Could not copy the file "C:\Umbraco9Test\umbraco\config\lang\en.xml" because it was not found.
1>  Microsoft.Common.CurrentVersion.targets(4996,5): error MSB3030: Could not copy the file "C:\Umbraco9Test\umbraco\config\lang\da.xml" because it was not found.

...

1>Done building target "_CopyOutOfDateSourceItemsToOutputDirectoryAlways" in project "Umbraco9Test.csproj" -- FAILED.
1>
1>Done building project "Umbraco9Test.csproj" -- FAILED.
1>
1>Build FAILED.

@OzoneNZ OzoneNZ changed the title Execute CopyUmbracoAssets @ BeforeBuild to prevent Rebuild failures Copy static assets during BeforeBuild target to prevent Visual Studio "rebuild" failures Sep 29, 2021
@OzoneNZ OzoneNZ changed the title Copy static assets during BeforeBuild target to prevent Visual Studio "rebuild" failures Copy static assets during BeforeBuild target to fix Visual Studio "rebuild" failures Sep 29, 2021
@umbrabot
Copy link

umbrabot commented Sep 29, 2021

Hi there @OzoneNZ, thank you for this contribution! 👍

While we wait for one of the Core Collaborators team to have a look at your work, we wanted to let you know about that we have a checklist for some of the things we will consider during review:

  • It's clear what problem this is solving, there's a connected issue or a description of what the changes do and how to test them
  • The automated tests all pass (see "Checks" tab on this PR)
  • The level of security for this contribution is the same or improved
  • The level of performance for this contribution is the same or improved
  • Avoids creating breaking changes; note that behavioral changes might also be perceived as breaking
  • If this is a new feature, Umbraco HQ provided guidance on the implementation beforehand
  • The contribution looks original and the contributor is presumably allowed to share it

Don't worry if you got something wrong. We like to think of a pull request as the start of a conversation, we're happy to provide guidance on improving your contribution.

If you realize that you might want to make some changes then you can do that by adding new commits to the branch you created for this work and pushing new commits. They should then automatically show up as updates to this pull request.

Thanks, from your friendly Umbraco GitHub bot 🤖 🙂

@p-m-j p-m-j changed the base branch from v9/contrib to v9/dev September 30, 2021 06:19
@p-m-j
Copy link
Contributor

p-m-j commented Sep 30, 2021

Works like a charm #h5yr!

@nathanwoulfe
Copy link
Contributor

Am I right in assuming package devs should be making a similar change in .targets to avoid the same issue?

@p-m-j
Copy link
Contributor

p-m-j commented Sep 30, 2021

@nathanwoulfe I guess that depends on if the packages need to write files into the project directories for editing by their users.

We're hoping to move away from these msbuild hacks to immutable content in nuget packages and package developers should try to do so where possible also.

  • If content files in the nupkg are only required when publishing/deploying, a nuspec with contentFiles will work great.
  • If it's just adding static files to wwwroot then a razor class library is probably better (basically does the same as contentFiles but with a handy file provider for debugging).
  • For immutable razor views it makes sense to embed them in the class library (or potentially use RCL's for distributing partials)
  • What we're doing here is last resort and requires cleanup.

@bergmania
Copy link
Member

Cherry picked to 9.0.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants