[Release] Mod Template for Visual Studio (Automatically configs, adds references and more!)

Currently Viewing (Users: 0, Guests: 1)

dealman

Sergeant
Best answers
1
Decided to try and create a project template for Visual Studio to make it a bit faster and less painful to create new mods for Bannerlord. This is the first time I've made a template so there may be some issues I haven't encountered yet. But hopefully it'll work out of the box for you!

Features
This is an extension for Visual Studio, that means it's a nicely bundled package which easily installs straight into VS. Once installed you can use this template when you create a new project - the template will then configure your new project so it's set-up for Bannerlord immediately. This includes configurations such as;

• Include a Readme.txt file containing some useful information and links.
• Automatically adds references to some of the Bannerlord assemblies. (Some that I deemed irrelevant are omitted, if you want them included let me know! This includes assemblies for Native, SandBox and StoryMode modules)
• Create a basic SubModule.cs class, inheriting from MBSubModuleBase class.
• Create a basic SubModule.xml file with the basic settings pre-configured for you.
• Automatically configures the Output Directory for building your mod.
• Automatically configures the Working Directory for debugging your mod.
• Automatically configures VS to use Bannerlord.exe for debugging your mod.
• Automatically configures the command-line arguments for Bannerlord.exe to include your mod.
• Can also fetch the mods last used by the game launcher and slap those into the above arguments in case your new mod needs to be tested with other mods.
• Automatically installs Harmony 2.0.0.9 so you can get to patching immediately.

More automatic processes such as these can be added with relative ease, such as including code examples such as patching a method. An example of adding a new behavior and/or model.

Installing
Installation is very simple, you simply execute the BannerlordModTemplateWizard.vsix file and Visual Studio will guide you through the rest. You can of course also download the source code and build it yourself if you prefer.

Uninstalling
Open Visual Studio -> Extensions (top toolbar) -> Manage Extensions -> Installed -> Choose the Bannerlord Mod Template and click Uninstall

Planned Features
• I dunno, suggest stuff?

Downloads
Source Code (GitHub) | Extension Installer 2.0.0 (.vsix) | Visual Studio Marketplace

If you encounter any bugs or have some suggestions feel free to either post them here or as new issues on GitHub!
 
Last edited:

dealman

Sergeant
Best answers
1
Changelog
Latest: Version 2.0.0

Version 2.0.0
[Fixed]: NuGet packages (harmony) are now optional and not forced to install anymore
[Changed]: Wizard interface is now built upon the WPF standard instead of the old Forms
[New]: Project has been refactored and restructured

Version 1.1.2
[Changed]: Default project name is now "Bannerlord_Mod_#" to help prevent whitespace issues.
[Fixed]: Platform Target is now x64, should prevent architecture mismatch warnings.
[Added]: A new and more appropriate icon for the template.

Version 1.1.0
[Updated]: Removed a bunch of unnecessary references to some Bannerlord assemblies from the project template. Some other fixes.
[Added]: HarmonyLib is now installed automatically. (Note: I don't think this process can be made optional. So if you don't need it - simply don't copy it to the output folder when building)
[Added]: Option for the template to use the same modules as last used by the game launcher(includes your project as well of course).
 
Last edited:

dealman

Sergeant
Best answers
1
Awesome does this prompt you to download the correct .net binaries as well?
You mean .NET Framework 4.7.2? I don't think so, but I can specify a target framework version and that should prompt them to download 4.7.2 I reckon?
 

Lord Blueberry

Recruit
WBWF&SNW
Best answers
0
I'm getting "This extension is not installable on any currently installed products." when trying to install the extension, can't really figure out why. Any tips?
 

dealman

Sergeant
Best answers
1
I'm getting "This extension is not installable on any currently installed products." when trying to install the extension, can't really figure out why. Any tips?
What version of Visual Studio are you using? Do you have .NET Framework 4.7.2 installed?

I made this template on Visual Studio 2019, so not quite sure if it works on older versions. I hope it does... 😅
 

Lord Blueberry

Recruit
WBWF&SNW
Best answers
0
That must be my mistake. I hadn't used Visual Studio in forever and didn't realize there was a 2019 version by now. I have no reason to hold on to 2017 so i'll just get the newer one. Thanks again
 

IDUnknown

Recruit
Best answers
0
Changelog
Latest: Version 1.1.2

Version 1.1.2
[Changed]: Default project name is now "Bannerlord_Mod_#" to help prevent whitespace issues.
[Fixed]: Platform Target is now x64, should prevent architecture mismatch warnings.
[Added]: A new and more appropriate icon for the template.

Version 1.1.0
[Updated]: Removed a bunch of unnecessary references to some Bannerlord assemblies from the project template. Some other fixes.
[Added]: HarmonyLib is now installed automatically. (Note: I don't think this process can be made optional. So if you don't need it - simply don't copy it to the output folder when building)
[Added]: Option for the template to use the same modules as last used by the game launcher(includes your project as well of course).
Getting "extension/package.json not found inside zip." error message when trying to install the .vsix
 

kalarhan

Python Saint
Count
WBNWVCWF&S
Best answers
33
@Lumos @Ra'Jiska can we mark this for a [tools] section (subforum) or sticky it? In order to not be missed in the mix of hundreds of mods

@dealman nice idea, this kind of toolset helps new modders that are not used for the workflow of C#. There is nothing more frustrating than messing with a new IDE, framework and lots of setup steps and having them not work for some reason (small mistakes).
 

dealman

Sergeant
Best answers
1
I'm pretty sure if you click cancel it creates the project anyway lol
Yeah, it does. Will have to look into how to actually cancel it. :ROFLMAO:

Edit: This is fixed for the next version, was an easy fix!

nice idea, this kind of toolset helps new modders that are not used for the workflow of C#. There is nothing more frustrating than messing with a new IDE, framework and lots of setup steps and having them not work for some reason (small mistakes).
Thanks! That's what I was hoping it would do. It also helps me create a bunch of random project I can leave unfinished much faster 😅
 
Last edited:

Ra'Jiska

Subforum Moderator
WF&SWBNWM&BVC
Best answers
1
@Lumos @Ra'Jiska can we mark this for a [tools] section (subforum) or sticky it? In order to not be missed in the mix of hundreds of mods
I've already discussed the creation of a subforum dedicated to the tools with the rest of the team. We are awaiting for more tools to appear before doing so. However this tool may indeed be very useful for beginners, I'll sticky it until we have a proper section for that.
 

Wise_apple

Regular
Best answers
0
Hello, I encounter some problem when installing this extension while using your extension installer, here the error log:

4/19/2020 12:31:23 AM - Searching for applicable products...
4/19/2020 12:31:23 AM - Found installed product - Global Location
4/19/2020 12:31:23 AM - Found installed product - Visual Studio Community 2017
4/19/2020 12:31:25 AM - VSIXInstaller.NoApplicableSKUsException: This extension is not installable on any currently installed products.
at VSIXInstaller.ExtensionService.GetInstallableData(String vsixPath, String extensionPackParentName, Boolean isRepairSupported, IStateData stateData, IEnumerable`1& skuData)
at VSIXInstaller.ExtensionPackService.IsExtensionPack(IStateData stateData, Boolean isRepairSupported)
at VSIXInstaller.ExtensionPackService.ExpandExtensionPackToInstall(IStateData stateData, Boolean isRepairSupported)
at VSIXInstaller.App.Initialize(Boolean isRepairSupported)
at VSIXInstaller.App.Initialize()
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)

I'm using Microsoft Visual Studio 2017. Thanks
 

Wise_apple

Regular
Best answers
0
Try this version and kindly report back if that works. Next version should be a bit more backwards compatible. :xf-smile:
The extension is successfull installed but when i try to create new project with using bannerlord extension an error was occurred:

The project file could not be loaded. An error occurred while parsing
EntityName. Line 21, posisition 25.