Skip to content

Commit

Permalink
feat: use msbuild to find dll path
Browse files Browse the repository at this point in the history
  • Loading branch information
Nsidorenco committed Jan 11, 2025
1 parent a43e352 commit c2bad80
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions lua/neotest-dotnet/vstest_wrapper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,26 @@ function M.get_proj_info(path)
return name:match("%.[cf]sproj$")
end, { upward = true, type = "file", path = vim.fs.dirname(path) })[1]

local dir_name = vim.fs.dirname(proj_file)
local proj_name = vim.fn.fnamemodify(proj_file, ":t:r")
local _, res = lib.process.run({
"dotnet",
"msbuild",
proj_file,
"-getProperty:OutputPath",
"-getProperty:AssemblyName",
"-getProperty:TargetExt",
}, {
stderr = false,
stdout = true,
})

local info = nio.fn.json_decode(res.stdout).Properties

local proj_dll_path =
-- TODO: this might break if the project has been compiled as both Development and Release.
vim.fs.find(function(name)
return string.lower(name) == string.lower(proj_name .. ".dll")
end, { type = "file", path = dir_name })[1]
local dir_name = vim.fs.dirname(proj_file)

local proj_data = {
proj_file = proj_file,
dll_file = proj_dll_path,
dll_file = vim.fs.joinpath(dir_name, info.OutputPath:gsub("\\", "/"), info.AssemblyName)
.. info.TargetExt,
proj_dir = dir_name,
}

Expand Down

0 comments on commit c2bad80

Please sign in to comment.