I am very confused because I created a new project in Visual Studio 2019. I have tried this three separate times with different projects, and each time it exports as a DLL instead of an EXE. Here are the steps to reproduce this problem:
- New project
- Console App (.NET Core)
- Set details for new project, and hit the "Create" button
- Add Microsoft.Win32.Registry NuGet package to project
- Add the following code:
using Microsoft.Win32;
using System;
namespace Key_Statistics_Startup_Changer {
class Program {
static void Main(string[] args) {
if (args[0] == "CREATE_STARTUP") {
RegistryKey rkey = Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
rkey.SetValue("Key Statistics", @"C:\Program Files\Key Statistics\Key Statistics.exe");
}
else if (args[0] == "REMOVE_STARTUP") {
RegistryKey rkey = Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
rkey.DeleteValue("Key Statistics");
}
}
}
}
- Build and run project
When I do this, the program does create or remove the desired registry from startup (what the code is trying to accomplish), when I input arguments through Visual Studio. However, when this project is built, my Key Statistics Startup Changer\bin\Debug
folder gives me a sub-directory netcoreapp2.1
with the following files:
Key Statistics Startup Changer.deps.json
Key Statistics Startup Changer.dll
Key Statistics Startup Changer.pdb
Key Statistics Startup Changer.runtimeconfig.dev.json
Key Statistics Startup Changer.runtimeconfig.json
I am positive that I have the right folder where it would export, and every time I re-create the steps (making sure I don't select C# DLL project), this happens.
What's the deal here?