Ads keep us online. Without them, we wouldn't exist. We don't have paywalls or sell mods - we never will. But every month we have large bills and running ads is our only way to cover them. Please consider unblocking us. Thank you from GameBanana <3

How to compile and use pkNX

A Tutorial for Pokemon Sword & Shield

No ads for members. Membership is 100% free. Sign up!

Updates

v1.5 2mo
  • Addition added video tutorial
v1.1 2mo
This tutorial assumes you have intermediate knowledge of installing software and navigating common computer tasks, as well as navigating your hard drive. To be blunt, if these prerequisite skills are out of reach then perhaps using unreleased software is a bit irresponsible.
Also, I of course do not take responsibility for any issues or damage to any of your equipment.

Also, right click images and open them in a new window to see them larger.

Step 1: Installing Visual Studio 2019
Do you know how to run an installer? Good. Do that.

Go to this page and download Visual Studio Community 2019. Not Visual Studio Code. When installing just go through the process like normal. If asked, all you need to install is this package:

Everything else can be left as default.


Step 2: Cloning the source code


Open Visual Studio 2019 and click on "Clone or check out code" on the right-hand side.

Enter this URL: https://github.com/kwsch/pkNX
Keep all of the other options default, just click "Clone."


Step 3: Compiling the source code

All of PPorg's software is dead-simple to compile. After the GitHub repo is finished being cloned by VS 2019, you will see a window similar to this:

On the right-hand side of the screen, right-click on "pkNX.sln"

Click "Build"

Step 4: Finding your binary
Depending on how fast your computer is, it will take a certain amount of time for the binary file to compile. When it is done, the bottom of the VS 2019 window will tell you "Build Succeeded" and also tell you where the actual .exe is.

Assuming that you kept all other options as default, the steps below will help you find it.
Hit the Win+R keys on your keyboard to open the "Run" prompt. In it, type Source like so:


In Windows Explorer, open repos, then pkNX, then pkNX.WinForms, then bin, then Debug.


This is your pkNX binary. These files need to be kept together. You can move them wherever you want on your hard drive, but they need to be together.

Step 5: Setting up your game files for pkNX
Obtain your Pokémon Sword or Shield romfs. Dump it yourself. Obtaining it is not in the scope of this guide.

When you have your romfs, you must structure them in a very specific way for pkNX to accept it. This is the best way to do it, using Sword as an example:

Have a top-level folder named Pokemon [Game]

Inside of that folder you put your clean, unedited romfs. 
In the same directory as the romfs folder, you need to have an exefs folder. 
It can be completely empty, but it needs to be there. 


Step 6: Using pkNX
Open your brand-new pkNX.exe and drag your top-level Pokemon Sword folder onto the window. It will load it in.

Using all of the actual elements of the tool is a bit complicated and outside of the scope of this guide, but what you need to know is this:
When you make your edits, the tool is keeping track of everything you changed. When you close pkNX, the software writes a file with the titleID of the game next to the romfs and exefs folders from step 5

This file gets loaded in with Atmosphere LayeredFS and is all you need to use your mod. You never need to actually edit the romfs folder.

When opening pkNX, if this Title ID folder exists, it will use it and display the modifications from it. If it does not, it will just base it off of the vanilla game and write a new folder.

Step 7: ???

Step 8: Profit

Anyway, I hope this helps.

Troubleshooting
Some users are having issues regarding an error message to the effect of
project.assets.json' not found and/or A numeric comparison was attempted on "$(MsBuildMajorVersion)" that evaluates to "" instead of a number, in condition "($(MsBuildMajorVersion) < 16)". 

This seems to happen when building on Windows 10. I was able to reproduce this in a clean VM with no variables and was able to fix it. 
Here is a video tutorial on how to fix these two issues: 


If you prefer a typed-out fix instead of watching and following a video, here is the old version: 
In VS 2019, go to View -> Other Windows -> Package Manager Console and enter dotnet build
When that finishes, if you still receive the numeric comparison issue, then follow these steps: 

1. In the right-hand side of VS 2019, double click the pkNX.sln file
2. Go to Tools -> NuGet Package Manager ->Manage NuGet Packages for this Solution
3. Under Installed, find Costura.Foddy and click on it.
4. On the right-hand side of the pane that appeared, select all of the pkNX choices and hit "uninstall"
5. Accept all of the resulting warnings and dialogue boxes
6. When it finishes, in the NuGet Package Manager, go to Browse and find Costura.Foddy
7. Do the same as step 4 but Install instead. Accept all of the warnings.

It should build properly after this.
Sign up to access this!
  • Drakogalaxy12 avatar
    Drakogalaxy12 Joined 13d ago
    Offline
    access_time 10d
    everything is ok until step 5, pkNX didn't recognize the game data, i made the romfs with hactool, is that the problem?
    Bananite
    URL to post:
  • access_time 1mo
    I'm new to switch hacking, but would this be possible in other CFW such as ReiNX, im asking since atmosphere is the one mentioned but I dont know which cfw to use :)
    Bananite
    URL to post:
  • access_time 1mo
    Hi! Nice tutorial ;)

    I have all finished but in the game the modifications don't work :/
    Bananite
    URL to post:
  • 1supermiguel avatar
    1supermiguel Joined 9mo ago
    Offline
    384 points Ranked 48272nd
    7 medals 1 rare
    • Returned 1000 times Medal icon
    • Returned 100 times Medal icon
    • One month a member Medal icon
    • 6 months a member Medal icon
    • Thanked 5 submitters Medal icon
    • Submission featured Medal icon
    access_time 2mo
    Nice!!! Now after applying the fix and proving everything works once and for all, I am happy to finally reward you the full points for writing up this tutorial! Keep it up! I look forward to your next project! :D
    • Win x 1
    Lover of the Lewd
    URL to post:
  • VanitysFire avatar
    VanitysFire Joined 1y ago
    Offline
    174 points Ranked 58537th
    access_time 2mo
    that solution indeed did fix the issue. i was wondering about it when the installed Costura.Foddy was at like v6.1 and what you reinstall is some 4.x, but it worked and will not complain.  thank you very much for this.
    • Agree x 1
    Bananite
    URL to post:
  • VanitysFire avatar
    VanitysFire Joined 1y ago
    Offline
    174 points Ranked 58537th
    access_time 2mo
    when trying to build pknx i get this error code below. doing some searching i found several possible fixes for getting the issue resolved. all of which so far has not worked. only causes 1k+ more errors to come up. 

    Assets file ~\obj\project.assets.json' not found. Run a NuGet package restore to generate this file.

    any suggestion on trying to get it fixed? judging by trying to research a fix, this seems to be a very very common occurrence with visual studios when building files. 
    Bananite
    URL to post:

Embed

Share banner
Image URL
HTML embed code
BB embed code
Markdown embed code

Credits

Key Authors
SuperOkazaki
SuperOkazaki Joined 1y ago
Offline
writer
Inspiration
1supermiguel
1supermiguel Joined 9mo ago
Offline
384 points Ranked 48272nd
7 medals 1 rare
  • Returned 1000 times Medal icon
  • Returned 100 times Medal icon
  • One month a member Medal icon
  • 6 months a member Medal icon
  • Thanked 5 submitters Medal icon
  • Submission featured Medal icon
requester

Submitter

SuperOkazaki avatar
SuperOkazaki Joined 1y ago
Offline
SuperOkazaki
Creator
Sign up to access this!
Sign up to access this!
Sign up to access this!

Game

Sign up to access this!

Category

Details

Difficulty Level
Intermediate

Attributes

Share

  • Share on Reddit
  • Share on Twitter
  • Share on Facebook
  • Best of the Banana
    Featured on Dec 7 2019
  • Best of Yesterday
    Featured on Dec 7 2019
  • Today's Pick
    Featured on Dec 6 2019
  • 2
  • 14.9k
  • 13
  • 2mo
  • 2mo
  • 2mo

More Other/Misc Tutorials