views:

1644

answers:

3

I just create a Solution that contains 3 projects.

Order by build order

  1. Silverlight Application that is included in /ClientBin of ASP.NET Web Application project

  2. Windows Form Application that is used to optimize all xap in /ClientBin when Visual Studio pass build (post-build event).

  3. ASP.NET Web Application that display Silverlight application in /ClientBin

When I build ASP.NET web application successfully, ClientBin directory in web application project contain 3 Xap Files. After that VS.net fire a post-build command event that executes the Windows Form application. Windows form optimize all Xap and remote 2 Xap Files from 3 Xap Files.

Finally, Vs.net copy 3 Xap files from Silverlight application project to ClientBin directory again. Why? I can't find any log about copy Xap files after post-build event (by using MSBuild project build output verbosity: Diagnostic)

Target "PostBuildEvent" in file "C:\Windows\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets":
  Task "Exec"
    Command:
    **T:\myProject\Higgs\Higgs\Higgs.Utils.WinApp\bin\Higgs.Utils.WinApp.exe mode=OptimizeXap clientbindir=T:\myProject\Higgs\Higgs\Higgs.Web.UI\ClientBin\ mainxapfilename=Higgs.Silverlight.UI**
  Done executing task "Exec".
Done building target "PostBuildEvent" in project "Higgs.Web.UI.csproj".
Target "CoreBuild" in file "C:\Windows\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets":
  Task "CallTarget" skipped, due to false condition; ('$(UnloadProjectsOnCompletion)'=='true') was evaluated as ('false'=='true').
  Task "CallTarget" skipped, due to false condition; ('$(UnloadProjectsOnCompletion)'=='true') was evaluated as ('false'=='true').
  Task "CallTarget" skipped, due to false condition; ('$(UnloadProjectsOnCompletion)'=='true') was evaluated as ('false'=='true').
Done building target "CoreBuild" in project "Higgs.Web.UI.csproj".
Target "AfterBuild" in file "C:\Windows\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets":
Done building target "AfterBuild" in project "Higgs.Web.UI.csproj".
Target "Build" in file "C:\Windows\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets":
  Building target "Build" completely.
  No input files were specified.
Done building target "Build" in project "Higgs.Web.UI.csproj".
Target "AfterRebuild" in file "C:\Windows\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets":
Done building target "AfterRebuild" in project "Higgs.Web.UI.csproj".
Target "Rebuild" in file "C:\Windows\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets":
  Building target "Rebuild" completely.
  No input files were specified.
Done building target "Rebuild" in project "Higgs.Web.UI.csproj".

Done building project "Higgs.Web.UI.csproj".

Update

I updated the build order by building the Windows Forms application. After build web application. Next, I use the Windows Dorm application post-build event to execute its EXE. Everything works fine. But I don't like this solution because It's very strange solution for me.

A: 

This doesn't quite address your scenario, but FYI the PostBuildEvent seems like the last step in the build process; you can learn more about the ordering by inspecting

c:\Windows\Microsoft.NET\Framework\v2.0.50727\Microsoft.Common.targets

which shows the msbuild logic.

Brian
But I think all silverlight application project copy all xap to clientbin again after web application project build finish. I don't know why. It's very strange.PS. I try to open xap file by 7-Zip(for lock file) before post-build event finish. But I can't found any error message in console of VS.net.
Soul_Master
A: 

I don't know what exactly is you problem, but if there is any dependency on your projects you should order them to build correctly.

Oakcool
A: 

I'm assuming that the projects reference each other? So:

  • ASP.NET Web App references at least the SilverLight App.
  • Win Forms App references the Silverlight App.

Visual Studio will automatically copy dependant files into the project hierarchy unless you tell it not to. so the steps Visual Studio will take are:

  1. Build SilverLight App, and copy its output to the Forms App and Web App
  2. Run any post build events defined in the "Build" tab for the SilverLight App project.
  3. Build the Win Forms App, and if it's referenced by anything else, copy the output appropriately.
  4. Run any post build events defined in the "Build" tab for the Win Forms App project.
  5. Build the Web App
  6. Run any post build events defined in the "Build" tab for the Web App project.
  7. Run any "After build" events defined through MSBuild.

Basically, most of the dependant moves happen before the post build events:

Task "FindUnderPath"
  Comparison path is "D:\Projects\PublicSites\WebTest".
  Path [...]
  [...]
Done executing task "FindUnderPath".
Task "FindUnderPath"
  Comparison path is "bin\".
  Path [...]
  [...]
Done executing task "FindUnderPath".
Task "FindUnderPath"
  Comparison path is "obj\Debug\".
  Path [...]
  [...]
Done executing task "FindUnderPath".
Task "RemoveDuplicates"
Done executing task "RemoveDuplicates".
Done building target "_CleanGetCurrentAndPriorFileWrites" in project
  "WebTest.csproj".
Target "IncrementalClean" in file 
  "c:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets":
Task "FindUnderPath"
  Comparison path is "bin\".
Done executing task "FindUnderPath".
Task "FindUnderPath"
  Comparison path is "obj\Debug\".
Done executing task "FindUnderPath".
Task "Delete"
Done executing task "Delete".
Task "RemoveDuplicates"
Done executing task "RemoveDuplicates".
Task "WriteLinesToFile"
Done executing task "WriteLinesToFile".
Done building target "IncrementalClean" in project 
  "WebTest.csproj".

Then the build and AfterBuild events happen.

My guess is that VS is noticing the output of the SilverLight app is different to the version it has under it, and so goes and fetches a new copy.

Zhaph - Ben Duguid
yes! I think so. How to disable fetching a new copy to ClientBin directory?
Soul_Master
Can you make the Web Project reference the XAPs output from the Win Forms project rather than the SilverLight project? That way you'd be getting the optimized versions rather than the originals?Or: Have the Win Forms app optimize the XAP's in the Client_Bin folder **after** the web app is built, rather than before.
Zhaph - Ben Duguid
I should create custom project/solution to do that.
Soul_Master