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 a SharePoint project that references (and includes in its package) a non-SharePoint project.

There is a class in my SharePoint project that references the non-SharePoint project, so has a using MySolution.MyNonSharePointProject; directive at the start of the file.

When I build my SharePoint project, it builds prefectly happily.

When I try to package my SharePoint project - via Deploy or Publish - I get build errors The type or namespace name 'MyNonSharePointProject' does not exist in the namespace 'MySolution' (are you missing an assembly reference?)

How does building my project via Build differ from building it via Deploy or Publish? Why am I getting this error?

share|improve this question
    
Do you have the other project build settings correct? ie: Any CPU, .NET 4? –  James Love Jun 5 '13 at 10:33
    
Yup, they're all .NET 4.5 and Any CPU. Correct me if I'm wrong, but I believe a standard Build would fail if these were incorrect. –  Rawling Jun 5 '13 at 10:36
    
Yeah it would fail. Last I saw stuff like this was in VS 2008... solution back then was to restart VS. Does doing this help at all? –  James Love Jun 5 '13 at 10:38
1  
I've tried that a couple times and on this occasion it doesn't help. I've also tried my other workaround for this problem - usually if you do a Clean then you can do a Deploy once before it breaks again - but again, on this occasion it doesn't help. –  Rawling Jun 5 '13 at 10:49
1  
Another workaround is to use CKS Dev and do a "Copy to GAC/Bin" instead of a full deploy. –  Rawling Aug 19 '13 at 23:16

4 Answers 4

You need to change the order of Additional Assemblies defined on the SharePoint package since in Visual Studio 2013, this now makes a difference. My issue (and I suspect yours) was that several of my non-SharePoint projects had dependencies on each other and had to be built in a particular order. This was not an issue in Visual Studio 2012.

To change the order in which the assemblies are built when you attempt to package/deploy your SharePoint project,

  1. First find out the order you want the non-SharePoint projects to be built based on the dependencies.
  2. In Visual Studio, open the Package.package file in the /Package folder of the SharePoint project.
  3. Click on the Advanced tab.
  4. Delete all of your non-SharePoint project references (the Deployment should work at this point in time).
  5. Add all of your non-SharePoint project references in the order that you determined in Step 1. If any of your non-SharePoint assemblies needs to be marked as a Safe Control, remember to add it in the Safe Controls section in the Add Assembly from Project Output dialog.

Your application should deploy and work normally now.

ALL credit to David Klein (http://ddkonline.blogspot.com/2013/10/build-and-packagepublish-behaviour.html)

share|improve this answer
2  
It's a nice idea, but (as tagged) I'm using Visual Studio 2012. –  Rawling Dec 4 '13 at 13:51
1  
I had the similar issue and was so frustrated. I was using VS2013 on SP2013. I fixed the issue following Ryan Shripat's post. It worked well and my solution is working as expected. Thanks Ryan!! -Karu –  Karu Sep 2 at 22:34
    
@Karu, good to know that this works for SP2013 as well! –  Ryan Shripat Sep 3 at 11:08

I had a similar issue with the exception that I migrated the Solution from SP 2010 to SP 2013 in VS 2012 and the projects which were being referred were SharePoint projects. I fixed the issue by removing the dll references which were added using "Project references" and then added the references by browsing to bin folder.

Source:

http://www.datazx.cn/Forums/en-US/fcf3215b-7e2c-4423-afaf-bff310b60216/action?threadDisplayName=problem-with-vs2012-and-sharepoint-2013-solution

share|improve this answer
1  
I don't see how that would work - relative path to bin folder is different in debug vs prod vs any other build configuration –  Andrey Jan 31 at 17:02

I tried all solutions described above, but none of them worked for me, what i did is removing all features from my solution package (sandbox solution with more than 100 features), then publish the package (no errors), and started to add the features again, a few each time and publishing again, i was doing this trying to detect a failing feature but then when i finished to add them all, the "publish solution" is working again... i tried it twice with different solutions and is working...

Please let me know if that worked for you

share|improve this answer
    
maybe the features should be added also in the correct order as project dependencies :o –  Fernando Rodríguez Feb 14 at 14:32

I experienced similar symptoms within an VS2012 project targeting SP2010 after I separated some code into a new class library within the VS solution. After separating the code, I could no longer get the automatic pre-deploy build to run in the correct order. I tried everything in this thread. But I stumbled into a solution. Normally I right-click on the project in VS and select 'Deploy'. Since this wasn't working, I tried the "Deploy MySolutionName" item under the Visual Studio BUILD menu. This one actually allowed the deployment to proceed. I'm not sure what the functional difference is, but it seems to work in my case.

share|improve this answer

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.