0

I have a solution containing a number of C# projects which builds for both .net framework 4.7.2 and net 7. Most of the projects target both frameworks, but some UI parts are net 4 only. All projects, including net 4-only ones are in a modern sdk-style format. The problem is that for these net 4-only projects I still need to copy content files to both output folders: common net 4 build folder and common net 7 one. These content files are used by server components. Clearly, I can resolve it by running a post-build command line step, copying files. But this would require to hardcode some output folders, not having net 7 as a build target I can't refer to its output folder. Somehow not elegant. Ideally I would like to add net 7 as a build target to that UI projects, but to block the generation of binaries, which is not possible anyway, they just won't compile. Just to copy content files. Is it possible? Some flag in an sdk-style project?

ElDog
  • 1,230
  • 1
  • 10
  • 21
  • What does the project file look like? Do you have the content files in there? – rene May 03 '23 at 07:29
  • @rene Of course I have. They are set to "Copy if newer" and therefore are copied to the output folder. But for net 4-only projects this would be only net 4 output folder. – ElDog May 03 '23 at 07:31
  • Okay, so we could add a new target to the project file to only copy the content files and then start an msbuild with that specific target in the post-build. – rene May 03 '23 at 07:37
  • Hmm... Trying to understand this. > we could add a new target to the project file to only copy the content files That's the whole purpose, but how? > and then start an msbuild with that specific target in the post-build If it only copies files, then why a post-build? A normal build will work. – ElDog May 03 '23 at 07:43
  • 1
    I think it is easier to do something like this: https://stackoverflow.com/a/48084486 instead of "building" without binaries. – rene May 03 '23 at 07:44
  • Yes, that Copy instruction is not ideal, but better than a command line, tx. – ElDog May 03 '23 at 07:45
  • 1
    remember that you already have the items that are marked as content. You can re-use those in the copy. In your case there is no need to create a new Itemgroup. – rene May 03 '23 at 07:50

0 Answers0