Looking for a good resource for building a SP 2007 WSP package in Visual Studio 2010 - sharepoint

I have an event handler feature that I've built for sharepoint 2007 and have deployed by moving the DLL to the GAC and creating Feature.xml and Elements.xml in the necessary folder and then installing them using the stsadm commands. I'm looking to avoid doing all this and instead have a WSP file that I can run to install the feature automatically in a production environment.
Thanks

Here's how I would proceed to convert your unmanaged items into a managed solution package in Visual Studio 2010:
Create an "Empty SharePoint Project".
Set the deployment target. In Solution Explorer, click the project node and look at the Properties pane. Set the Assembly Deployment Target property between GlobalAssemblyCache and WebApplication. In this case, we'd leave it as the default GlobalAssemblyCache.
Note also there's a handy property called Include Assembly In Package. This is used to exclude your default project assembly from the output package. Why do you need this? If your project contains no code: for example, you're just bundling up some third-party DLLs for deployment.
Replace your SharePoint DLL references. Follow the steps in Adam Macaulay's article to remove the v14 DLLs and add back the v12 DLLs.
Add an Event Receiver item. Right-click your project and point to Add > New Item... and select "Event Receiver". Give the event receiver a proper name and click Add.
Configure the Event Receiver. Visual Studio will connect to your (2010) SharePoint instance, then prompt you with a wizard to walk you through what events you want to handle and for which item types. The end result is an Event Receiver item in your solution with a stubbed-out class that overrides the proper methods, as well as an Elements.xml file that is configured appropriately. If you have both of these files already, you don't really need to complete the wizard "truthfully"... just select the first option, click Finish and let Visual Studio create the Event Receiver and corresponding Feature.
Add your code logic. In Solution Explorer, expand your Event Receiver node to reveal the .CS class and the corresponding Elements.xml. Copy the contents of your existing files into those locations.
Configure the package feature. In Solution Explorer, expand the "Features" node and locate the default feature (Feature1.feature). This was created when you added the Event Receiver item. For clarity's sake, rename the feature to something logical, then double-click it to open the feature in design mode. You should see your Event Receiver has already been added to the right-most pane ("Items in the Feature"). Were there others, you could selectively add/remove items from the feature. Here is the place you set the feature scope between Farm/Site/Web/WebApplication.
Also importantly, while in the Feature designer, notice the Properties pane has a wealth of additional options to set on the Feature. These can't be accessed any other place, so keep in the back of your mind that is where to find them.
Lastly, if you click the Manifest tab at the bottom of the designer, you can preview what the feature manifest will look like. The manifest can be manually edited if need be (effectively disabling the designer), but I have yet to find something I need to do that I can't configure via properties.
Configure the overall package. In Solution Explorer, expand the "Package" node and locate the default package (Package.package). Just as for features, double-click the package to open it in design mode. This is the same UI that features use, allowing you to pick which features will be part of this package. Your event receiver feature should already be added to the right-most pane ("Items in the Package").
Again, same as features, while you're in Package design mode, the Properties pane will make available certain properties that can't be edited elsewhere. Most notably, it is here you should clear the value out of SharePoint Product Version.
Also, we have the same manifest preview available to us via the Manifest tab at the bottom of the screen. This is handy for checking things like SafeControl entries (if you need them) and the like. The Assembly entry should reflect the correct deployment target (in this case GlobalAssemblyCache) that was set on the project.
Finally, the Advanced tab allows you to specify additional assemblies/SafeControl entries to the package, which is helpful if you're bundling up additional DLLs to the default project DLL.
Build your project. Obviously we want to make sure it compiles!
Test the deployment. When I test, I deploy to my 2010 instance first (because it's handy) and double-check that everything has been installed as I expected: DLL in the correct place (BIN/GAC), appropriate Web.config entries created, feature installed at the right scope, feature activates properly, etc.
Package the solution. Point to your Build > Package menu item. The WSP will be placed in the appropriate output folder for the active configuration. Test deploy to your SharePoint 2007 instance.

Check out "Build a SharePoint 2007 Web Part with a Visual Studio 2010 Visual Web Part Project" written by Adam Macaulay. I used this as a reference when I wanted to do the same, and the methodology works great. I've successfully converted a lot of our Visual Studio 2008 projects to 2010 projects, while maintaining compatibility with SharePoint 2007 environments.
I will make one suggestion: if you don't absolutely need the Visual Designer for your web part (i.e. your web part's output is made programmatically), then using the Visual Web Part template adds extra "junk" to your solution which I dislike.
Rather, in step 1 create instead an "Empty SharePoint Project", then right-click on your Project in the Solution Explorer and point to Add > New Item... and select "Web Part" (not "Visual Web Part"). You don't end up with the ASCX control and you can ignore the parts of Adam's tutorial that deal with updating the Register declarations.
This also has the added benefit of capturing the correct name for the web part files up front, so you don't have to rename a bunch of "VisualWebPart1xxx" files.

Related

Create Form Template from existing ones

Is there any way that I can create a template within forms to utilize for every user in the company?
For instance; let's say I have the Sales Order Screen (SO301000) and the Document Detail grid configured in certain way, that display different amount of columns than the default (either more or less columns).
For each user I want to use this template (and all the ones created) that I will apply when I add the new user.
I'l appreciate any guidance and help.
EDIT:
I provided answer for Form element ASP template below. Although reading your question again I think what you're trying to do would be more along the lines of automating grid column configuration. We call this feature Default Table Layout.
There's a feature request for it here:
https://feedback.acumatica.com/ideas/ACU-I-415
The feature has been shipped in version 2017R2 and is documented here:
https://help.acumatica.com/(W(1))/Main?ScreenId=ShowWiki&pageid=30f3229f-20f1-4055-9c03-e0fe3b37080d
Image copy of documentation page:
For ASP Form templates
There are two ways to work with customizations in Acumatica:
As a Customization Project, everything is done directly in Acumatica
instance through the web browser using the Customization Project Editor.
As an extension library (DLL file) compiled in Visual Studio which is then included in the FILES section of a Customization Project.
For method 1, I believe creating custom templates would be a bit of a hack and would not be officially supported, if someone knows otherwise please chime in.
For method 2, we ship the Visual Studio templates with the Acumatica Configuration Wizard (Acumatica ERP Installer).
Those templates are in the following folder:
My Documents\Visual Studio 20XX\Templates\ItemTemplates\Visual C#
The templates will be available for ASP.NET solution only. You can open Acumatica Instance Website as a solution if the website is already deployed:
When you open Add New Item dialog:
The Acumatica Templates will be available:
Those are standard Visual Studio templates so you can copy and re-use them to create your own. Microsoft documentation for creating user template applies and you can follow their guidelines. Note that working with Visual Studio and creating your own template is somewhat less user friendly than using Acumatica Customization Project Editor.
Acumatica T100 covers using Visual Studio to create customizations and would be a good starting point to learn the techniques involved:
https://openuni.acumatica.com/courses/development/t100-introduction-to-acumatica-framework/

Set a custom application Icon for a Class Library deployed using ClickOnce

I have a C# project in VS2012 with an output type set to "Class Library", in fact it is a VSTO word 2010 add-in, after publishing the project and installing it with ClickOnce, I notices that the icon used in the "Programs and Features" list is the default icon, which is not really professional IMO. I would like to be able to set a custom icon for my application but as its a Class Library I'm having a really hard time figuring out how to do it.
In the "Application" tab of my project properties in the "Resources" section, the "Icon and Manifest" option is selected by default but it is disabled so I can't select and Icon file. I fear there is no way to do it for a class library project, but I haven't found any confirmation of this either.
Thanks for any informatin/help you might give.
After searching for a couple hours I think this is not possible right now, see this link that I posted in a comment on the OP above. Its a bit sad as it would look a lot more profesional if we could put a custom application icon on a vsto addin that would be visible in the Programs and Feature list in the control panel...

SharePoint 2010 VS development: Intellisense for ASPX files

I'm using Visual Studio 2010 to develop a SharePoint Server 2010 solution. Part of this includes custom Page Layouts, but when editing them, intellisense is completely broken, since Visual Studio doesn't appear to know how to handle them. Here's what I've done:
Created a new blank solution
Right-clicked on the solution and created a new "Empty SharePoint Project"
Right-clicked on the project and created a new "Module"
Renamed sample.txt to MyPageLayout.aspx or created a new ASPX Web Form
At this point, intellisense for the new Page Layout is broken. It gets even worse with tools like ReSharper installed. Also, things like "Format Document" will break the Page Layout (by for example changing asp:Content to asp:content)
What I've tried to get intellisense working:
Added a Web.config from a standard Web Application Project to the root of the SharePoint Project - made no difference.
Added the ProjectGuid for a Web Application Project to the SharePoint project file - broke the project.
Is there any way to get intellisense, and the rest of the support Visual Studio can offer for Web Forms, available when developing SharePoint 2010 Page Layouts?
I have followed your post to some extent.
Using VS2010 (On an x64 machine)
Create a blank SharePoint solution. (this properly combines your #1 & #2)
Add a module (in SharePoint a module is like a folder or resource container)
added a new class to the module (intellisense present)
Added a new webpart to the module (intellisense present)
added a user control to the project designer works and (intellisense present)
I believe that you should consider creating true server or visual web parts. This will have a harder learning curve but will pay with dividends in the future. You will be able to package and deploy your solution again or to another server/farm. Aspx pages can be added and manipulated by the dreaded SharePoint designer. In 2010 the theory is that those designer mods can be packaged and deployed.
I work in this environment every day and the best advice I can give is to embrace the SP object model and do 'it' the sharepoint way. Don't try to force SP to be something its not. :)
This is probably not the solution you are looking for but it's the best thing I found for SharePoint development.
In your solution, create 2 projects :
1 SharePoint Project (empty or not)
1 ASP.NET web application project
Develop all your UI (aspx pages, ascx controls, etc.) in your ASP.NET project and create post-build steps that will copy the pages and controls to the appropriate folders in your SharePoint solution.
That way, you will benefit from all the features of web development in visual studio and it will be very easy to deploy as well. It is a bit of a time investment at first, but it is well worth it if you have any considerable amount of logic to implement in your aspx pages.
This blog post documents what you need to do.
you can add an intellsense to pagelayouts by closing the page and simply reopen it from
file->openfile->your file page layout path
Or you can directly "Right Click" on the file you want to open from the Solution explorer and then select "Open" : you'll get the Intellisense !

how do I mark a file as a data file in a visual studio 2010 vsto clickonce application?

I'm making a Word 2007 add-in with C# 4.0 in Visual Studio 2010. I need an Access 2007 database (a .accdb file) to be placed in the data directory by the clickonce installer. Unfortunately, the file is getting put elsewhere, so the application can't find it at runtime. I've seen various articles refer to using the Application Files dialog on the Publish tab of the project properties to mark the file as a data file, but I have no Application Files button for some reason.
Any idea how to make the Application Files dialog appear, or some other way to manually mark my .accdb file as a data file?
In the Solution Explorer, if you set the file's property to be Copy to Output Directory = Copy Always. Then when you go to Application Files they should default as a Data File.
However, since this is your database I would consider looking at make it safe across updates so you might consider this post.
See http://msdn.microsoft.com/en-us/library/dd465298.aspx
By the way, "Application Files" button should be on the project properties' Publish tab.
VSTO Applications do not have the Application Files button available, and you can't set the file types specifically. If your file is not being deployed to the data directory and you want it to be, rename it with a file extension that is marked by ClickOnce as data. This includes .xml, .mdb, and .mdf. Otherwise, the file is deployed with the VSTO application and will be in the same location as the rest of the files.
The location of the deployment files for a VSTO application can be discovered programmatically this way:
System.Reflection.Assembly.GetExecutingAssembly.CodeBase
You might want to move the database, though, because unless you deploy it as data, it will be lost when an update is performed. Or you can check out this article about where to put your data to keep it safe from ClickOnce updates.
I was able to get things to work by using the Mage tool as described here:
http://msdn.microsoft.com/en-us/library/6fehc36e.aspx
The trick with MageUI is it's open file dialog assumes you want to open a manifest associated with a .exe; a vsto project has a .dll, so the manifest doesn't appear in the files list by default, which was really tripping me up.
Basically, this process is a pain because you have to remember to do it manually. I don't know if there's a way to make this part of the build (maybe a post-build step? But this is really a post-publish step).

Using WSPBuilder to build a solution for a web part I developed

I have only ever deployed web parts from development by clicking F5. Now, I know I have to have a manifest file, feature file, etc and it all goes into a wsp file. I understand the wsp file is what gets added to Central Admin.
So my problem is this. I have found lots of sites that show how to use WSP Builder, but they don't seem to show how/where I add my web part to the WSP Builder project. My understanding is that somehow I should be able to use WSP Builder to create a wsp file containing my already-developed web part.
There are only two approaches that I see would work.
I create a WSPBuilder project (like all the how-tos on WSPBuilder show), then I assume I would somehow add my web part to that project - although I don't know how.
In my web part project, create WSPBuilder -> Build WSP. I have done this, and when I run stsadm on the resulting wsp file, I get it in Central Admin, but its not added to my Site Collection Features or my Web Part Gallery.
Can someone please explain this to me like I am a 6 year old? If you point me to another site, there is a good chance I have already seen it, so then I would ask you point me to the specific lines that tell me how to get my already existing web part packaged into the wsp.
To create a new web part feature with WSPBuilder:
Right-click on the name of your WSPBuilder project in Visual Studioand click Add, New Item.
Select WSPBuilder from the tree on the left and choose Web Part Feature from the list on the right of the dialog.
Enter the title of the web part feature and click OK.
In the dialog that appears enter the title, description and scope and click OK.
Your feature will now be created. You will then need to merge your existing web part code into this feature and configure its XML files.
Read this walkthrough by Tobias Zimmergren for more information. There is another walkthrough here.
Alex, got the right path to solve it. I think the small exception here is that wrongly spelt Add New Item instead of New Project.

Resources