Can I deploy in SharePoint two Web Parts with the same DLL, but two .webpart files, at the same time - sharepoint

Is it possible to have two Web Parts with the same DLL, but two .webpart files, deployed in Sharepoint at the same time?
Background :
I am developing an application that will generate a ".cab" file containing a Web Part (ASP.NET 2.0 Web Part). After that, the user should be able to deploy this ".cab" file in a in a SharePoint server.
My application already includes the DLL of a Web Part. The "behavior" of this Web Part depends on the properties of the ".webpart" file which will be generated at runtime by my application (its content will change depending on certain user choices)
After generating the ".webpart" file, it packages it to a ".cab" file along a Manifest.xml and the DLL.
Imagine that the user creates two "cab" files using my application. And he wants to deploy them into SharePoint.
To test this, I create this two ".cab" files with my app, and in SharePoint I execute:
$> STSADM.EXE -o addwppack <cab filename #1>
$> STSADM.EXE -o addwppack <cab filename #2>
$> STSADM.EXE -o deletewppack <cab filename #1>
After the execution of the third command, the Web Part #2 doesn't have the DLL.
When I installed Web Part #2, SharePoint override the DLL file of Web part #1
The problem here is that the DLL of both files is copied to same location. That location is the Assembly name of DLL. That assembly name cannot be changed without recompiling again (I think).
Is there anyway to deploy two cab files independently, even if they share the same DLL?

You could split your application in 2 parts: a 'library' that contains only your dll. And something that deploys the .webpart file only.
Users must always keep the 'library' part installed..
Also, you might want to look at alternatives from installing a 'wpppack'.. the .webpart file is nothing more than a file in a library in your sites.. may be easier to add that than to install a .cab on the server.

This shouldn't be an issue at all. A .webpart file simply points to a class within an assembly, and provides the configuration values for a specific instance of that class. If you want to have multiple configurations of your webpart available from the webpart gallery, you would go about it by uploading multiple .webpart files which reference the same class. For example, every instance of the listview webpart can be exported to a .webpart file, but they are all using the same webpart class. Check this blog posting for more info on the contents of the .webpart file.

Related

Edit a file on IIS Manager by wix installer

My requirement is to edit a .xap file which is already in the IIS Manager.. when install another web application on IIS manager. (I want to add the end points of a web application in the previous web application .xap file)
You could write a custom action to:
Open the .xap file (it's a .zip file named differently)
Extract the file(s) that need to be modified
Edit the extracted file(s)
Re-zip the extracted file(s) back into the .xap file.
You could find the existing .xap file using AppSearch of some sort. Maybe a FileSearch element. Most of the work is going to be in your custom action though. Good luck!
Please see Mike's answer over at:
NSIS Changing config file present in XAP file i.e. silverlight component build
There's two parts here:
1) Authoring the Silverlight application to use an external config file.
2) Authoring your installer to update that config file. In this case of WiX, it's the XmlConfig element in the Util extension.
The reasons for doing it this way is to have a highly reliable installer. If you write custom actions to extract, edit and compress the XAP you'll invalidate digital signatures and introduce complexity and fragility to your deployment process. Avoiding the temptation to do all this and just use XmlConfig gives you a robust, declarative installation that fully supports the Windows Installer rollback story.

Copy external linked file to a root of a web site

In Visual Studio 2012
I have three web sites that all use the same set of database connection strings.
I keep database connections strings in a connectionStrings.config file which is in a common solution folder (external to all three web sites).
I included this file as a link (configured as Content and Copy Always) - which copies connectionString.config file to each web site's bin folder when I compile/run web site.
I would like to copy that file to the root of each web site instead. Is there an easy way to accomplish that?
One way to do this is to use xcopy in post-build step of the project.
The other solution would be to modify .csproj file (or a separate, external .target file) to copy linked file to the root (instead of to $(OutputDir))
I used a Post-Build event. It has macro's for the place you want the file to end up.
Just use the $(Macro) tags with a few "..", and you can "massage" the files to where you want them.
copy $(ProjectDir)..\connectionStrings.config $(TargetDir)connectionStrings.config

Sharepoint Deployment

I am creating an .STP for a site. But here I have a DLL file in BIN , a XAP file in 12 Hive Folder and few more custom entries in teh Web.Config. How do I include there in the .STP File? When I say IncludeContent when I create a .STP file for the Site , then also the above said things are not getting included.
There is not a way I know of that you can modify an exported STP file.
It is possible you could try renaming the extension to ZIP or CAB, see if you can view the file, check for the presence of the a Manifest.xml file and attempt to modify that way. Have never tried though
A Site Template will not export your web.config settings, 12 hive files or assemblies. All of these can be provisioned through a SharePoint solution file (WSP) though. I would suggest researching how to create and deploy those.

Deploying a file to the filesystem using MOSS Solutions and Features

I have a .browser file that I need to deploy to the following location:
c:\browsers\
as part of a moss .wsp file. Can I do this in the manifest.xml or as part of a feature?
It is not possible. You can use the wsp solution to deploy any File to
Inside 12 Hive Folder Hierarchy
GAC
bin Folder of the Web Application.
Rest of the other location you need to look out for the custom solution. One option I can say is to use a Feature Installed event and keep it a Farm Feature.

Use an XML File with a Feature

Currently I have a custom Web Part, deployed as a Feature, and it accesses an XML file as follows:
string sUri = #"C:\inetpub\wwwroot\wss\VirtualDirectories\80" + #"\wpresources\links.xml";
ds = new DataSet();
ds.ReadXml(sUri);
What is the correct way to include an XML file as part of a SharePoint Feature deployment?
Load it into the 12 hive under your layouts directory and link to it via
http://[currentsite]/[currentweb]/_layouts/links.xml
. Or add a subdirectory to group all of your file together. e.g.
http://[currentsite]/[currentweb]/[myFeature]/_layouts/links.xml
how do I include it in the Feature
project...?
I am using STSDEV and that automagically puts an entry into the manifest.xml under
<Templates>
e.g.
<TemplateFile Location="LAYOUTS\[myFeature]\links.xml" />
In my mind there are a few correct ways.
The place you want to deploy your xml file I would not pick however.
It would have to be either:
deployed directly in the 12-hive using a solution file (like Nat suggests, I'd use WSPBuilder though)
deployed to the site using a feature ( see: http://msdn.microsoft.com/en-us/library/ms441170.aspx )
this would make the file be pushed into the content database for your code to read.
To my knowledge there is no simple way of deploying files to the InetPub folder for your website. I needed this once to deploy a .browser file and ended up creating a feature receiver that copied the file from the 12-hive into the InetPub folder.
Maybe if you explain what the xml file is for, the answers can be better :)

Resources