Make changes in wsp file programmatically - sharepoint-2010

What I currently need is to programmatically make certain changes in existing wsp file. Most likely wsp file will be created using "Save site as template" SharePoint action - and I'll need to update it.
What api/approach would you recommend to accomplish this task? Please note that .NET C# is mandatory. Some approaches/questions I could see now:
Do you guys know some 3rd party tool allowing "friendly" object model to work with WSP files? I could not find one.
Do you know is there any special assemblies that could be used for this in WSPBuilder or Visual Studio 2010?
What CAB tool would you recommend? Because it seems there are not so much .NET solutions to work with CAB files.

You can use cablib.dll . Its the same API library which the WSP BUilder uses.
Note that making changes like this programmatically is not recommended and by deploying it might put your server into unsupported mode.
http://www.codeproject.com/KB/files/CABCompressExtract.aspx

Related

VS 2019 Custom ASP.NET Core project templates

I'm trying to figure out how (or even if) I can create a custom Visual Studio project template that hooks into the existing ASP.NET Core Web Application template available in Visual Studio 2019?
What I want to do is something similar to madskristensens ASP.NET Core Template Pack (GitHub source code). However instead of VS 2017 I want to do this for VS 2019's revamped "New Project Dialog" window. So imagine adding an additional ASP.NET Core web application template in the place highlighted below.
I am able to create new project templates (both for Visual Studio and for dotnet new) but nothing has worked thus far. Has anyone been able to extend VS 2019 in this way, or was this taken away after VS 2017?
After doing some more investigation between both VS 2017 and 2019 (Community) I was able to successfully figure this out! Man oh man do we need some docs on this because this felt like a doozy!
I was able to use the ASP.NET Core Template pack as a building block for putting something together. For those who don't know, the extensions are designed to add templates to Visual Studio using .nupkg file(s) embedded in the extension. The use of the .nupkg files is similar to how dotnet new works with custom templates. I've got a working prototype on GitHub that supports both Visual Studio 2017 and 2019.
Now if you're like me, you may look at either madskristensens or my project and ask "How in the heck does this work!?" Great question! Here are the details I have the time to fill out right now:
Build out a custom template (or templates) and place them into *.nupkg file(s)
In my sample, my SampleTemplates project contains three different project templates. I generate the .nupkg with dotnet pack
A vs-2017.3.host.json file is required in the .template.config/ folder so that the ASP.NET Web Application wizard can display the template.
At least 1 or more other requirements need to be fulfilled to be displayed in the ASP.NET Web Application wizard, but I haven't yet figured those out, as adding the file to a console app template doesn't cause it to appear. I want to try and figure this out, although I'd love help if anyone already knows!
The template.json needs a Framework symbol to define the list of .NET Core framework targets that are supported by the template.
In doing some testing, it didn't look like the Framework symbol didn't substitute into the .csproj, so that is why my example also includes a TargetFrameworkOverride symbol that the Framework symbol replaces.
Place the .nupkg file(s) into the root of a VSIX extension project and make sure to set the "Include in VSIX" flag to True. I emphasize root because originally I had the NuGet package landing in a build\ folder in my extension and my templates weren't being picked up.
I'll try to put together a README in my example project to provide a better outline of all of the details required to accomplish this. Fingers crossed this helps someone out (or at least help me out in the future when I inevitably forget how I accomplished this)!
Update
As of September 2nd, 2020, the Visual Studio team released an experimental feature to include dotnet new templates within Visual Studio. I have done some exceptionally minimal testing with it, and it does appear to work, but it's not perfect. For example, I created a dotnet new template that scaffolds multiple .csproj files and .sln file, and the output didn't quite match my solution.
This is the Visual Studio blog post describing the announcement: https://devblogs.microsoft.com/dotnet/net-cli-templates-in-visual-studio/

Migrate custom XAML build workflow to TFS 2017 extensions

I currently have a custom XAML build workflow which performs a lot of validations based on code structure, folders, file content and even database configuration.
Currently we need to consider to migrate it to TFS 2017, and I'm trying to understand the possibilities, effort and pitfalls and this is where I could use your help.
I have logic built in C# and then I look at MSDN documentation the language seems to be Javascript, GitHub samples seem to be Typescript. Am I forced to use one of this languages? any preferred one or limitations that I should be aware of? Can for instance, I connect to a database directly? or it's better to have an API and just use REST calls?
Can I for instance, use .Net object which have already some wrapped logic?
I also noticed that on the manifest file I can declare inputs, but can I somehow use outputs? For example, I have a task that does validation and in the end I would have a task to send an e-mail with the result of that validation. Is this possible?
Thank you in advance.
You are right in concluding that XAML builds are deprecated. The new Task based system is much more flexible and now that we even have YAML support, you can move to Builds as Code.
The reason you're seeing Build Tasks in TypeScript (which is a superset of JavaScript) because of the cross platform nature of NodeJS. This allows your tasks to run on Windows, Linux and Mac. In the mean time we also got .NET Core support. You can also use PowerShell if that's more of your liking.
Regarding your 'can I connect to a database' question. Yes you can, if you want it is another question. This will massively slow your build down and will make your build fail if there are issues with database connectivity. I would suggest asking a second question here on Stackoverflow to describe your situation and discuss if there is a better alternative.
You can use output variables from your task and reuse these in the next tasks. That's all supported and no problem (see https://roadtoalm.com/2016/08/11/set-output-variable-in-a-powershell-vsts-build-task/ for an example).
There are too many questions here and they are broad.
Whatever, XAML Build are deprecated in TFS 2017 and will not be available in the next version of TFS. VSTS already no longer supports them. So you need to Migrate from XAML builds to new builds (vNext builds). Also this similar thread for your reference : Converting TFS XAML Build Custom Activities into TFS 2015 Build Tasks
Marketplace
While you can make use of custom build tasks with XAML build there is
no centralized or integrated solution for browsing available tasks,
installing them or managing them. With the new builds you can make use
of the quickly-growing Visual Studio Team Services Marketplace. Here,
you can search and browse the many extensions currently available in
the Marketplace.
See WHY SHOULD I LEAVE XAML BUILDS for details.
So, you can find the existing extensions in Marketplace and install them to extend the build process (add correspinding tasks). You can also custom your own extension based on your specific requirements. See Extensions overview.
You can build custom applications or services that integrate with your
Visual Studio Team Services (VSTS) and Team Foundation Server (TFS)
accounts by using the REST APIs to make direct HTTP calls, or
utilize our .NET Client Libraries.
Source here : Integrating with VSTS and Team Foundation Server
To add a custom task you can reference below articles:
Add a build task
Reference for creating custom build tasks within extensions
Developing a Custom Build vNext Task
For the "outputs" validation, you can try it with build alerts.

Creating new web application from WSP file

A web application is installed on our sharepoint server. I have the WSP and dll files for the solution but not the source code. I need to make some changes in the code of the webpages of that application so I have to create a new web application with exact same functionality from scratch so that I have full control. How can I use the WSP and DLL files to create a new solution.
I have imported the WSP package in vs2010 and decompiled the dll file to get code behinds of aspx pages.
You can give a shot to tools that reflect on code. You will be able to generate a lot of code OOB using ILSpy. Give it a shot.

Getting MVC4 error in Studio 2010 Pro

File C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft Corporation\NuGet Package Manager\1.5.20902.9026\Modules\NuGet\profile.ps1 cannot be loaded because the execution of scripts is disabled on this system.
I would like to piggyback another :
Why does a new MVC4 project not come with a unit test project? It is not letting me check the box for that.
And one more thing : why is it not including the MicrosoftMVCAjax scripts in the scripts folder?
I am finding I can write a working JSONapp with partial views and callbacks if I have this one from an older MVC2 or 3 project.
Thanks!
You should be able to create check the unit test project check box for the Internet and Intranet project templates.
We are de-emphasizing the use of Microsoft AJAX scripts in MVC templates and instead focusing on the jQuery family of scripts. However, you can still use the scripts if you copy them from an existing MVC 2 or 3 project.

Deploying wsp from MSI installer

I would like to deploy a SharePoint 2010 solution package (wsp) using MSI (or some other user friendly form of installer).
I know I can create a custom action and deploy everything using the SharePoint object model, but I don't think that's the way to go.
What would be the way to do this?
There is an upcoming project on it, read about it here:
http://sharepointinstaller.codeplex.com/wikipage?title=SpecificationV2&referringTitle=Home
Currently, the best way would be to use MSI with CustomAction. But instead of object model, use powershell script to deploy the WSP. It will much cleaner than code.
http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2009/12/02/adding-and-deploying-solutions-with-powershell-in-sharepoint-2010.aspx