0

I have a csproj file that copies shared (linked) files on build, like this:

  <Target Name="CopyLinkedContentFiles" BeforeTargets="Build">
    <Copy SourceFiles="%(None.Identity)" DestinationFiles="%(None.Link)" SkipUnchangedFiles="true" OverwriteReadOnlyFiles="true" ContinueOnError="true" Condition="'%(None.Link)' != ''" />
  </Target>

I use it for core ts and css files. Now, every time I change something in these files, I have to rebuild in order for these files to be updated in the opened solution.

Is there a way I can do any of these:

  1. Manually trigger the copy of one of these files
  2. Make a task to automatically copy on save any of these files
  3. Some other way I cannot foresee?

thanks!

user5328504
  • 734
  • 6
  • 21

1 Answers1

0

The only way to invoke a target in a project file is to start msbuild. If you don't want the Build target to be called (which is essentially what building in VS does: call msbuild /t:Build), you could add an external command (go to 'Tools->External Tools...') and assign a button and/or keyboard shortcut to it. The command should be 'msbuild.exe' (full path if needed), the arguments '$(ProjectDir)$(ProjectFileName) /t:CopyLinkedContentFiles'.

stijn
  • 34,664
  • 13
  • 111
  • 163
  • Well! It actually worked! A few comments: I had to point to the proper msbuild.exe which in my case was {path to visual studio 2017}\MSBuild\15.0\Bin\msbuild.exe. I also had to give it a menu position and map a keyboard shortcut. So, all in all, this was a great answer. Thanks! – user5328504 May 02 '17 at 14:48
  • Yeah sorry I forgot the VS instance in which I tried it was started from the VS commandline so had msbuild in the path already – stijn May 02 '17 at 14:49