tags:

views:

929

answers:

4

hello, I have a project for all my javascripts in side (that i made common for three projects), I want upon build to move these scripts to the three projects, how can i do this by editing .csproject and how? Thanks

A: 

If you can use Visual Studio to build then use post build events in visual studio. Failing that if you have access to the command line just issue a copy command

Adam Naylor
+1  A: 

There is two ways to do that:

_ Edit the .csproject, at the end of the file you should find a Target named AfterBuild (uncomment the target).

<ItemGroup>
    <JavascriptFiles Include="*.js"/>
</ItemGroup>

<Target Name="AfterBuild">
    <Copy
        SourceFiles="@(JavascriptFiles)"
        DestinationFolder="PathWhereYouWantToCopyYourJavascriptFiles"
    />
</Target>

_ Post build events in visual studio (in project properties)

madgnome
A: 

I have in the same solution webapplication1 and webapplication2 and im editing .csproject for webapplication1, and i want to copy all files in test folder

  <Target Name="AfterBuild">
    <Copy SourceFiles="$(WDTargetDir)test\" 
          DestinationFolder="$(SolutionRoot)WebApplication2">
    </Copy>
  </Target>

nothing is happening????

Targets BeforeBuild and AfterBuild are commented by default. It could be that.
madgnome
man ofcourse i removed the comment :$
You must pass a Items to SourceFiles, here you just pass a directory. See http://msdn.microsoft.com/fr-fr/library/3e54c37h.aspx for more informations.
madgnome
thx for ur reply, but how can i move these files to the second project which is in the same solutionDestinationFolder="$(SolutionRoot)WebApplication2" is creating a folder name webapplication2 in my source application
A: 
  <Target Name="AfterBuild">
    <Copy SourceFiles="test\CodeFile1.cs" 
          DestinationFolder="..\WebApplication2\scripts">
    </Copy>
  </Target>

This was the solution thx anyway :)