DotNetSurfers

Latish Sehgal's Blog

Sharing Resources Between Asp.Net Projects

If you need to share resources such as images and javascript files between different Asp.Net projects, an easy way to do it is to:

  • Move the assets in a common location.
  • Right click on project and choose “Add Existing Item”
  • Navigate to shared resources and click on “Add As Link”
  • Open your project file in a text editor and update the “AfterBuild” Target.

      <Target Name="AfterBuild">
          <!-- Delete old copies of linked files -->
          <Delete Condition=" '%(Content.Link)' != '' AND Exists('$(WebProjectOutputDir)\%(Content.Link)') " Files="$(WebProjectOutputDir)\%(Content.Link)" />
          <!-- Copy linked files -->
          <Copy Condition=" '%(Content.Link)' != '' " SourceFiles="%(Content.Identity)" DestinationFiles="$(WebProjectOutputDir)\%(Content.Link)" />
      </Target>
    

This makes sure that the linked content is copied while maintaining the folder structure.

P.S If you are interested in tools that make you more productive, and work with Sql Server Management Studio, you should check out SqlSmash.

Comments