Skip to content

Commit

Permalink
Merge pull request #5 from mhlabs/fix/path_to_binary
Browse files Browse the repository at this point in the history
fix: path argument and finding the project name
  • Loading branch information
ljacobsson authored Sep 26, 2023
2 parents e0ce21a + 30bdcbb commit d62d307
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
13 changes: 5 additions & 8 deletions net/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,15 @@ static void Main(string[] argv)
var name = argv[2];
var cwd = argv[3];
var typeName = argv[4];
Program.assemblyName = typeName + ".dll";
//binFolderPath = @"/home/lars/code/mathem/address-service/address_service/bin/Debug/net6.0";
Program.binFolderPath = Path.Combine(cwd, "bin", "Debug", "net6.0");
if (!Directory.Exists(Program.binFolderPath))
Program.assemblyName = typeName;
if (!Directory.Exists(binFolderPath))
{
Program.binFolderPath = Path.Combine(cwd, typeName, "bin", "Debug", "net6.0");
binFolderPath = Path.Combine(cwd, typeName, "bin", "Debug", "net6.0");
}

if (!Directory.Exists(Program.binFolderPath))
if (!Directory.Exists(binFolderPath))
{
throw new Exception("Could not find bin folder. Please run 'dotnet build' from the project root.");
return;
}

if (command == "list")
Expand Down Expand Up @@ -89,7 +86,7 @@ public static void Attach()
private static Assembly? ResolveDependency(object sender, ResolveEventArgs args)
{
var name = args.Name.Split(",")[0];
string path = Path.Combine(Program.binFolderPath, name + ".dll");
string path = Path.Combine(Program.binFolderPath, name);
if (loadedAssemblies.Contains(args.Name)) return null;
loadedAssemblies.Add(args.Name);
if (File.Exists(path))
Expand Down
8 changes: 5 additions & 3 deletions src/commands/create/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,11 @@ async function nodejs(cmd) {
async function dotnet(cmd) {
try {
const netPath = path.resolve(__dirname, "..", "..", "..", 'net');
const cwd = process.cwd();
const projectName = path.basename(cwd).replace(/-/g, '_');
const proc = execSync(`dotnet run ${path.resolve(cmd.path)} list ${projectName} ${process.cwd()} ${projectName}`, { cwd: netPath });
const binFolderPath = cmd.path ? path.resolve(cmd.path) : process.cwd();
const binFolderFiles = fs.readdirSync(binFolderPath);
// Get the project name from the dll in the bin folder
const projectName = binFolderFiles.filter(file => path.extname(file).toLowerCase() === '.dll')[0];
const proc = execSync(`dotnet run ${path.resolve(cmd.path)} list ${projectName} ${binFolderPath} ${projectName}`, { cwd: netPath });
const types = proc.toString().split('\n').sort().filter(p => p && p.length && !p.includes(" warning "));
const file = await inquirer.prompt({
type: 'list',
Expand Down

0 comments on commit d62d307

Please sign in to comment.