Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have two projects in my VS solution, a project named "B" is a SharePoint 2010 project which has a mapped SharePoint "Layouts\js" folder and some other project "A".

In project "B" I put various files in the "Layouts\js" folder which are deployed when I hit deploy from VS2010. But if I add existing item from project "A" "someFile.js" with the option "Add As Link" to "Layouts\js" in project "B", the linked item is not deployed when I hit deploy from VS2010.

Why does this not work?

I want to be able to have only one copy of "someFile.js" across both projects, and I want "someFile.js" to be deployed in "Layouts\js" when I hit Deploy from VS2010.

How can I achieve this?

share|improve this question
add comment

1 Answer

The link won't be handled by the package builder.

You can, however, edit manually the spdata file to "link" the files.

For example, I use this technique to link resources files. I have to deploy resx both in \14\resources and \app_globalresources. To avoid duplicating the file, I change the spdata file like this :

<ProjectItem 
    Type="Microsoft.VisualStudio.SharePoint.GenericElement" 
    DefaultFile="Elements.xml" 
    SupportedTrustLevels="All" 
    SupportedDeploymentScopes="Web, Site, WebApplication, Farm, Package"         xmlns="http://schemas.microsoft.com/VisualStudio/2010/SharePointTools/SharePointProjectItemModel">
  <Files>
    <ProjectItemFile Source="Elements.xml" Target="App_GlobalResources\" Type="ElementManifest" />
    <ProjectItemFile Source="..\Resources\my.resx"
                     Type="AppGlobalResource"/>
    <ProjectItemFile Source="..\Resources\my.fr-FR.resx"
                     Type="AppGlobalResource"/>
  </Files>
</ProjectItem>

When the package will be build, the files will be taken from the relative path.

More on this in this article.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.