summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2026-04-19 22:59:34 +0800
committerGitHub <[email protected]>2026-04-19 22:59:34 +0800
commit1813ff50ab7bd0cbddd2d7f9e510f7a2309fa4c9 (patch)
treeca11c14b9f0d213c2fe39953999e02770d55c072
parentfabb25749492d6b26887da0217486bfbfd104bdd (diff)
parent839a0b74facd029e4b13aa2a6657abfdaa445964 (diff)
Merge pull request #7489 from xmake-io/csharp
vsxmake: generate .csproj for C# targets
-rw-r--r--tests/plugins/project/test.lua53
-rw-r--r--xmake/plugins/project/vsxmake/getinfo.lua26
-rw-r--r--xmake/plugins/project/vsxmake/vsxmake.lua21
-rw-r--r--xmake/scripts/vsxmake/vsproj/Xmake.CSharp.targets165
-rw-r--r--xmake/scripts/vsxmake/vsproj/Xmake.props8
-rw-r--r--xmake/scripts/vsxmake/vsproj/Xmake.targets14
-rw-r--r--xmake/scripts/vsxmake/vsproj/Xmake.xml2
-rw-r--r--xmake/scripts/vsxmake/vsproj/templates/Xmake.Custom.props2
-rw-r--r--xmake/scripts/vsxmake/vsproj/templates/csproj/#target#.csproj50
-rw-r--r--xmake/scripts/vsxmake/vsproj/templates/csproj/File.cs(filecs)1
-rw-r--r--xmake/scripts/vsxmake/vsproj/templates/csproj/ProjectConfiguration(mode,arch)4
-rw-r--r--xmake/scripts/vsxmake/vsproj/templates/csproj/ProjectRef(dep)3
-rw-r--r--xmake/scripts/vsxmake/vsproj/templates/csproj/XmakeConfig(mode,arch)14
-rw-r--r--xmake/scripts/vsxmake/vsproj/templates/csproj/XmakePath(mode,arch)7
-rw-r--r--xmake/scripts/vsxmake/vsproj/templates/sln/Project(target)2
-rw-r--r--xmake/scripts/vsxmake/vsproj/templates/vcxproj/XmakePath(mode,arch)2
16 files changed, 355 insertions, 19 deletions
diff --git a/tests/plugins/project/test.lua b/tests/plugins/project/test.lua
index 168e71f1a..40edd6a3a 100644
--- a/tests/plugins/project/test.lua
+++ b/tests/plugins/project/test.lua
@@ -2,6 +2,7 @@ import("core.project.config")
import("core.platform.platform")
import("core.tool.toolchain")
import("lib.detect.find_tool")
+import("detect.sdks.find_dotnet")
function test_vsxmake(t)
@@ -56,6 +57,58 @@ function test_vsxmake(t)
os.tryrm(tempdir)
end
+function test_vsxmake_csharp(t)
+
+ if not is_subhost("windows") then
+ return t:skip("wrong host platform")
+ end
+
+ local dotnet = find_dotnet()
+ if not dotnet or not dotnet.sdkver then
+ return t:skip("dotnet sdk not found")
+ end
+
+ local projname = "testcsproj"
+ local tempdir = os.tmpfile()
+ os.mkdir(tempdir)
+ os.cd(tempdir)
+
+ -- create a C# console project using xmake create
+ os.vrunv("xmake", {"create", "-l", "csharp", "-t", "console", projname})
+ os.cd(projname)
+
+ -- create sln & csproj
+ local arch = os.getenv("platform") or "x64"
+ local vs = config.get("vs")
+ local vstype = "vsxmake" .. vs
+ os.execv("xmake", {"project", "-k", vstype, "-a", arch})
+ os.cd(vstype)
+
+ -- verify a .csproj was generated (not .vcxproj)
+ local csproj_path = path.join(projname, projname .. ".csproj")
+ assert(os.isfile(csproj_path), "expected .csproj to be generated at " .. csproj_path)
+ assert(not os.isfile(path.join(projname, projname .. ".vcxproj")),
+ "unexpected .vcxproj generated for C# target")
+
+ -- verify .sln references the .csproj with the C# project type GUID
+ local sln_text = io.readfile(projname .. ".sln")
+ assert(sln_text:find("FAE04EC0-301F-11D3-BF4B-00C04F79EFBC", 1, true),
+ "C# project type GUID missing from .sln")
+ assert(sln_text:find(projname .. ".csproj", 1, true),
+ ".csproj reference missing from .sln")
+
+ -- verify the .csproj imports Xmake.CSharp.targets and has a Compile item
+ local csproj_text = io.readfile(csproj_path)
+ assert(csproj_text:find("Xmake.CSharp.targets", 1, true),
+ "Xmake.CSharp.targets import missing from .csproj")
+ assert(csproj_text:find("<Compile Include=", 1, true),
+ "<Compile> item missing from .csproj")
+
+ -- clean up
+ os.cd(os.scriptdir())
+ os.tryrm(tempdir)
+end
+
function test_compile_commands(t)
local projname = "testproj"
local tempdir = os.tmpfile()
diff --git a/xmake/plugins/project/vsxmake/getinfo.lua b/xmake/plugins/project/vsxmake/getinfo.lua
index 9395657fd..60b20b9c4 100644
--- a/xmake/plugins/project/vsxmake/getinfo.lua
+++ b/xmake/plugins/project/vsxmake/getinfo.lua
@@ -89,6 +89,20 @@ function _make_arrs(arr, sep)
return table.concat(r, sep or ";")
end
+-- detect project kind (csharp vs cxx) so vsxmake emits .csproj for C# targets
+function _get_projkind(target)
+ local sourcekinds = table.wrap(target:sourcekinds())
+ if #sourcekinds == 0 then
+ return "cxx"
+ end
+ for _, sk in ipairs(sourcekinds) do
+ if sk ~= "cs" then
+ return "cxx"
+ end
+ end
+ return "csharp"
+end
+
-- get values from target
function _get_values_from_target(target, name)
local values = {}
@@ -122,6 +136,7 @@ function _make_targetinfo(mode, arch, target)
-- save target kind
targetinfo.kind = target:kind()
+ targetinfo.projkind = _get_projkind(target)
-- is default?
targetinfo.default = tostring(target:is_default())
@@ -497,6 +512,17 @@ function main(outputdir, vsinfo)
_target.vcxprojdir_relative_sln = vsutils.translate_path(path.relative(_target.vcxprojdir, vsinfo.solution_dir))
_target.target_id = hash.uuid4(targetname)
_target.kind = target:kind()
+ if not _target.projkind then
+ _target.projkind = _get_projkind(target)
+ if _target.projkind == "csharp" then
+ -- C# project type GUID, see https://www.codeproject.com/Reference/720512/List-of-Visual-Studio-Project-Type-GUIDs
+ _target.projtypeguid = "FAE04EC0-301F-11D3-BF4B-00C04F79EFBC"
+ _target.projext = "csproj"
+ else
+ _target.projtypeguid = "8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942"
+ _target.projext = "vcxproj"
+ end
+ end
_target.absscriptdir = target:scriptdir()
_target.scriptdir = path.relative(target:scriptdir(), _target.vcxprojdir)
_target.projectdir = path.relative(project.directory(), _target.vcxprojdir)
diff --git a/xmake/plugins/project/vsxmake/vsxmake.lua b/xmake/plugins/project/vsxmake/vsxmake.lua
index b52b160a9..cd61dfcbf 100644
--- a/xmake/plugins/project/vsxmake/vsxmake.lua
+++ b/xmake/plugins/project/vsxmake/vsxmake.lua
@@ -31,6 +31,7 @@ import("vstudio.impl.vsutils", {rootdir = path.join(os.programdir(), "plugins",
local template_root = path.join(os.programdir(), "scripts", "vsxmake", "vsproj", "templates")
local template_sln = path.join(template_root, "sln", "vsxmake.sln")
local template_vcx = path.join(template_root, "vcxproj", "#target#.vcxproj")
+local template_csproj = path.join(template_root, "csproj", "#target#.csproj")
local template_fil = path.join(template_root, "vcxproj.filters", "#target#.vcxproj.filters")
local template_props = path.join(template_root, "Xmake.Custom.props")
@@ -146,6 +147,9 @@ function _buildparams(info, target, default)
elseif args.filets then -- for qt/.ts
local files = info._targets[target].sourcefiles
table.insert(r, _filter_files(files, {".ts"}))
+ elseif args.filecs then -- for c#
+ local files = info._targets[target].sourcefiles
+ table.insert(r, _filter_files(files, {".cs"}))
elseif args.incc then
local files = table.join(info._targets[target].headerfiles or {}, info._targets[target].extrafiles)
table.insert(r, _filter_files(files, nil, {".natvis"}))
@@ -239,14 +243,21 @@ function make(version)
for _, target in ipairs(info.targets) do
local paramsprovidertarget = _buildparams(info, target, "<!-- nil -->")
- local vcxproj_dir = info._targets[target].vcxprojdir
+ local _target = info._targets[target]
+ local vcxproj_dir = _target.vcxprojdir
+ local projkind = _target.projkind or "cxx"
+ local projext = _target.projext or "vcxproj"
-- write project file
- local vcxproj_file = path.join(vcxproj_dir, target .. ".vcxproj")
- _writefileifneeded(vcxproj_file, render(template_vcx, "#([A-Za-z0-9_,%.%*%(%)]+)#", "@([^@]+)@", paramsprovidertarget))
+ local proj_file = path.join(vcxproj_dir, target .. "." .. projext)
+ local proj_template = (projkind == "csharp") and template_csproj or template_vcx
+ _writefileifneeded(proj_file, render(proj_template, "#([A-Za-z0-9_,%.%*%(%)]+)#", "@([^@]+)@", paramsprovidertarget))
- local vcxproj_filters = path.join(vcxproj_dir, target .. ".vcxproj.filters")
- _writefileifneeded(vcxproj_filters, render(template_fil, "#([A-Za-z0-9_,%.%*%(%)]+)#", "@([^@]+)@", paramsprovidertarget))
+ -- .csproj does not use a .filters sidecar (legacy .vcxproj-only mechanism)
+ if projkind ~= "csharp" then
+ local vcxproj_filters = path.join(vcxproj_dir, target .. ".vcxproj.filters")
+ _writefileifneeded(vcxproj_filters, render(template_fil, "#([A-Za-z0-9_,%.%*%(%)]+)#", "@([^@]+)@", paramsprovidertarget))
+ end
-- add project custom file
_trycp(template_props, vcxproj_dir)
diff --git a/xmake/scripts/vsxmake/vsproj/Xmake.CSharp.targets b/xmake/scripts/vsxmake/vsproj/Xmake.CSharp.targets
new file mode 100644
index 000000000..2ac8336f5
--- /dev/null
+++ b/xmake/scripts/vsxmake/vsproj/Xmake.CSharp.targets
@@ -0,0 +1,165 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+
+ <PropertyGroup Label="XmakePathsResolve">
+ <XmakeBuildDirResolved>$(XmakeBuildDir)</XmakeBuildDirResolved>
+ <XmakeTargetDirResolved>$(XmakeTargetDir)</XmakeTargetDirResolved>
+ <XmakeConfigDirResolved>$(XmakeConfigDir)</XmakeConfigDirResolved>
+ <XmakeConfigFileDirResolved>$(XmakeConfigFileDir)</XmakeConfigFileDirResolved>
+ <XmakeRunDirResolved>$(XmakeRunDir)</XmakeRunDirResolved>
+
+ <!-- resolve if they are relative paths -->
+ <XmakeBuildDirResolved Condition="!$([System.IO.Path]::IsPathRooted('$(XmakeBuildDirResolved)'))">$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(XmakeBuildDirResolved)'))</XmakeBuildDirResolved>
+ <XmakeTargetDirResolved Condition="!$([System.IO.Path]::IsPathRooted('$(XmakeTargetDirResolved)'))">$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(XmakeTargetDirResolved)'))</XmakeTargetDirResolved>
+ <XmakeConfigDirResolved Condition="!$([System.IO.Path]::IsPathRooted('$(XmakeConfigDirResolved)'))">$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(XmakeConfigDirResolved)'))</XmakeConfigDirResolved>
+ <XmakeConfigFileDirResolved Condition="!$([System.IO.Path]::IsPathRooted('$(XmakeConfigFileDirResolved)'))">$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(XmakeConfigFileDirResolved)'))</XmakeConfigFileDirResolved>
+ <XmakeRunDirResolved Condition="!$([System.IO.Path]::IsPathRooted('$(XmakeRunDirResolved)'))">$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(XmakeRunDirResolved)'))</XmakeRunDirResolved>
+
+ <!-- normalize paths -->
+ <XmakeBuildDirResolved>$([System.IO.Path]::GetFullPath('$(XmakeBuildDirResolved)/'))</XmakeBuildDirResolved>
+ <XmakeTargetDirResolved>$([System.IO.Path]::GetFullPath('$(XmakeTargetDirResolved)/'))</XmakeTargetDirResolved>
+ <XmakeConfigDirResolved>$([System.IO.Path]::GetFullPath('$(XmakeConfigDirResolved)/'))</XmakeConfigDirResolved>
+ <XmakeConfigFileDirResolved>$([System.IO.Path]::GetFullPath('$(XmakeConfigFileDirResolved)/'))</XmakeConfigFileDirResolved>
+ <XmakeRunDirResolved>$([System.IO.Path]::GetFullPath('$(XmakeRunDirResolved)/'))</XmakeRunDirResolved>
+
+ <!-- these paths resolved in Xmake.Default.props, just normalize -->
+ <XmakeProgramDirResolved>$([System.IO.Path]::GetFullPath('$(XmakeProgramDir)/'))</XmakeProgramDirResolved>
+ <XmakeProgramFileResolved>$([System.IO.Path]::GetFullPath('$(XmakeProgramFile)'))</XmakeProgramFileResolved>
+ <XmakeProjectDirResolved>$([System.IO.Path]::GetFullPath('$(XmakeProjectDir)/'))</XmakeProjectDirResolved>
+ <XmakeScriptDirResolved>$([System.IO.Path]::GetFullPath('$(XmakeScriptDir)/'))</XmakeScriptDirResolved>
+ </PropertyGroup>
+
+ <PropertyGroup Label="XmakeInternal">
+ <_XmakeProjectFlag Condition="'$(XmakeProjectFile)' != ''">-F "$(XmakeProjectFile)"</_XmakeProjectFlag>
+ <_XmakeProjectFlag Condition="'$(XmakeProjectFile)' == ''">-P .</_XmakeProjectFlag>
+
+ <_XmakeCommonFlags>$(XmakeCommonFlags.Trim())</_XmakeCommonFlags>
+ <_XmakeCommonFlags Condition="$(XmakeVerbose)">-v $(_XmakeCommonFlags.Trim())</_XmakeCommonFlags>
+ <_XmakeCommonFlags Condition="$(XmakeDiagnosis)">-D $(_XmakeCommonFlags.Trim())</_XmakeCommonFlags>
+ <_XmakeCommonFlags>-y $(_XmakeCommonFlags.Trim()) $(_XmakeProjectFlag)</_XmakeCommonFlags>
+
+ <_XmakeOutFlag>-o "$([MSBuild]::MakeRelative('$(XmakeProjectDirResolved)', '$(XmakeBuildDirResolved)').TrimEnd('\').TrimEnd('/'))"</_XmakeOutFlag>
+
+ <_XmakeConfigFlags>$(XmakeConfigFlags.Trim())</_XmakeConfigFlags>
+ <_XmakeConfigFlags>-p $(XmakePlat) -m $(XmakeMode) -a $(XmakeArch) $(_XmakeOutFlag) $(_XmakeConfigFlags.Trim())</_XmakeConfigFlags>
+
+ <_XmakeBuildFlags>$(XmakeBuildFlags.Trim())</_XmakeBuildFlags>
+
+ <_XmakeBuildFileFlags>$(_XmakeBuildFlags.Trim())</_XmakeBuildFileFlags>
+ <_XmakeBuildFileFlags Condition="$(XmakeRebuildFile)">$(_XmakeBuildFileFlags.Trim()) -r</_XmakeBuildFileFlags>
+
+ <_XmakeCleanFlags>$(XmakeCleanFlags.Trim())</_XmakeCleanFlags>
+ <_XmakeCleanFlags Condition="$(XmakeCleanAll)">-a $(_XmakeCleanFlags.Trim())</_XmakeCleanFlags>
+
+ <_XmakeBuildFlags>$(_XmakeBuildFlags.Trim())</_XmakeBuildFlags>
+ <_XmakeBuildFileFlags>$(_XmakeBuildFileFlags.Trim())</_XmakeBuildFileFlags>
+ <_XmakeCleanFlags>$(_XmakeCleanFlags.Trim())</_XmakeCleanFlags>
+ <_XmakeConfigFlags>$(_XmakeConfigFlags.Trim())</_XmakeConfigFlags>
+ <_XmakeCommonFlags>$(_XmakeCommonFlags.Trim())</_XmakeCommonFlags>
+ <_XmakeTarget>"$(XmakeTarget.Trim())"</_XmakeTarget>
+
+ <_XmakeExecutable>"$([System.IO.Path]::GetFullPath('$(XmakeProgramFileResolved)'))"</_XmakeExecutable>
+ <_XmakeEnv>
+ pushd $(XmakeProjectDirResolved)
+ set XMAKE_CONFIGDIR=$(XmakeConfigDirResolved.TrimEnd('\').TrimEnd('/'))
+ set XMAKE_PROGRAM_DIR=$(XmakeProgramDirResolved.TrimEnd('\').TrimEnd('/'))
+ set XMAKE_PROGRAM_FILE=$(XmakeProgramFileResolved.TrimEnd('\').TrimEnd('/'))
+ set XMAKE_SKIP_HISTORY=1
+ set XMAKE_IN_VSTUDIO=1
+ </_XmakeEnv>
+ <_XmakeEnv Condition="$(XmakeDiagnosis)">
+ $(_XmakeEnv)
+ echo XMAKE_CONFIGDIR=%25XMAKE_CONFIGDIR%25
+ echo XMAKE_PROGRAM_DIR=%25XMAKE_PROGRAM_DIR%25
+ echo XMAKE_PROGRAM_FILE=%25XMAKE_PROGRAM_FILE%25
+ echo CD=%25CD%25
+ </_XmakeEnv>
+ </PropertyGroup>
+
+ <Target Name="_XmakeProjCheck">
+ <Error Condition="!Exists('$(XmakeProgramFileResolved)')"
+ Text="xmake.exe not found at '$(XmakeProgramFileResolved)'" />
+ <Error Condition="'$(XmakeProjectFile)' == '' And !Exists('$(XmakeProjectDirResolved)\xmake.lua')"
+ Text="xmake.lua not found at '$(XmakeProjectDirResolved)', please set XmakeProjectDir in csproj file" />
+ <Error Condition="'$(XmakeProjectFile)' != '' And !Exists('$(XmakeProjectDirResolved)\$(XmakeProjectFile)')"
+ Text="$(XmakeProjectFile) not found at '$(XmakeProjectDirResolved)', please set XmakeProjectDir in csproj file" />
+ </Target>
+ <Target Name="_XmakeConfig" DependsOnTargets="_XmakeProjCheck">
+ <Message Text="$xmake config $(_XmakeCommonFlags) $(_XmakeConfigFlags)" Importance="High" />
+ <Exec Command="$(_XmakeEnv)
+ $(_XmakeExecutable) config $(_XmakeCommonFlags) $(_XmakeConfigFlags)" EchoOff="true" />
+ </Target>
+ <Target Name="_XmakeBuild" DependsOnTargets="_XmakeProjCheck">
+ <Message Text="$xmake build $(_XmakeCommonFlags) $(_XmakeBuildFlags) $(_XmakeTarget)" Importance="High" />
+ <Exec Command="$(_XmakeEnv)
+ $(_XmakeExecutable) build $(_XmakeCommonFlags) $(_XmakeBuildFlags) $(_XmakeTarget)" EchoOff="true" />
+ </Target>
+ <Target Name="_XmakeRebuild" DependsOnTargets="_XmakeProjCheck">
+ <Message Text="$xmake build -r $(_XmakeCommonFlags) $(_XmakeBuildFlags) $(_XmakeTarget)" Importance="High" />
+ <Exec Command="$(_XmakeEnv)
+ $(_XmakeExecutable) build -r $(_XmakeCommonFlags) $(_XmakeBuildFlags) $(_XmakeTarget)" EchoOff="true" />
+ </Target>
+ <Target Name="_XmakeBuildFile" DependsOnTargets="_XmakeProjCheck">
+ <ItemGroup>
+ <SelectedFile Include="$(SelectedFiles)" />
+ <File Include="$([MSBuild]::MakeRelative('$(XmakeProjectDirResolved)', $([System.IO.Path]::GetFullPath('%(SelectedFile.Identity)'))))" />
+ </ItemGroup>
+ <PropertyGroup>
+ <FileFlag>--files="@(File)"</FileFlag>
+ </PropertyGroup>
+ <Message Text="$xmake build $(_XmakeCommonFlags) $(_XmakeBuildFileFlags) $(FileFlag) $(_XmakeTarget)" Importance="High" />
+ <Exec Command="$(_XmakeEnv)
+ $(_XmakeExecutable) build $(_XmakeCommonFlags) $(_XmakeBuildFileFlags) $(FileFlag) $(_XmakeTarget)" EchoOff="true" />
+ </Target>
+ <Target Name="_XmakeClean" DependsOnTargets="_XmakeProjCheck">
+ <Message Text="$xmake clean $(_XmakeCommonFlags) $(_XmakeCleanFlags) $(_XmakeTarget)" Importance="High" />
+ <Exec Command="$(_XmakeEnv)
+ $(_XmakeExecutable) clean $(_XmakeCommonFlags) $(_XmakeCleanFlags) $(_XmakeTarget)" EchoOff="true" />
+ </Target>
+
+ <Target Name="BeforeBuild" />
+ <Target Name="AfterBuild" />
+ <Target Name="Build" Condition="'$(DesignTimeBuild)' != 'true'">
+ <CallTarget Targets="BeforeBuild" />
+ <CallTarget Targets="_XmakeConfig;_XmakeBuild" />
+ <CallTarget Targets="AfterBuild" />
+ </Target>
+
+ <Target Name="BeforeClean" />
+ <Target Name="AfterClean" />
+ <Target Name="Clean" Condition="'$(DesignTimeBuild)' != 'true'">
+ <CallTarget Targets="BeforeClean" />
+ <CallTarget Targets="_XmakeConfig;_XmakeClean" />
+ <CallTarget Targets="AfterClean" />
+ </Target>
+
+ <Target Name="BeforeRebuild" />
+ <Target Name="AfterRebuild" />
+ <Target Name="Rebuild" Condition="'$(DesignTimeBuild)' != 'true'">
+ <CallTarget Targets="BeforeRebuild" />
+ <CallTarget Targets="_XmakeConfig;_XmakeRebuild" />
+ <CallTarget Targets="AfterRebuild" />
+ </Target>
+
+ <Target Name="BeforeBuildFiles" />
+ <Target Name="AfterBuildFiles" />
+ <Target Name="BuildFiles" Condition="'$(DesignTimeBuild)' != 'true'">
+ <CallTarget Targets="BeforeBuildFiles" />
+ <CallTarget Targets="_XmakeConfig;_XmakeBuildFile" />
+ <CallTarget Targets="AfterBuildFiles" />
+ </Target>
+ <!-- override default C# compile to call xmake instead of csc -->
+ <Target Name="CoreCompile" Condition="'$(DesignTimeBuild)' != 'true'">
+ <CallTarget Targets="BuildFiles" />
+ </Target>
+
+ <ImportGroup Label="CustomTargets">
+ <!--only search 2 levels to avoid accidentally import-->
+ <Import Condition="Exists('$(MSBuildProjectDirectory)\Xmake.Custom.targets')"
+ Project="$(MSBuildProjectDirectory)\Xmake.Custom.targets" />
+ <Import Condition="!Exists('$(MSBuildProjectDirectory)\Xmake.Custom.targets') And Exists('$(MSBuildProjectDirectory)\..\Xmake.Custom.targets')"
+ Project="$(MSBuildProjectDirectory)\..\Xmake.Custom.targets" />
+ </ImportGroup>
+</Project>
diff --git a/xmake/scripts/vsxmake/vsproj/Xmake.props b/xmake/scripts/vsxmake/vsproj/Xmake.props
index e2bf58dfe..6bde5d90a 100644
--- a/xmake/scripts/vsxmake/vsproj/Xmake.props
+++ b/xmake/scripts/vsxmake/vsproj/Xmake.props
@@ -29,9 +29,9 @@
</PropertyGroup>
<PropertyGroup Label="XmakePathsFallback">
- <XmakeBuilDDir Condition="'$(XmakeBuilDDir)' == ''">$(XmakeProjectDir)\build</XmakeBuilDDir>
- <XmakeTargetDir Condition="'$(XmakeTargetDir)' == ''">$(XmakeBuilDDir)\$(XmakePlat)\$(XmakeArch)\$(XmakeMode)</XmakeTargetDir>
- <XmakeConfigFileDir Condition="'$(XmakeConfigFileDir)' == ''">$(XmakeBuilDDir)\$(XmakePlat)\$(XmakeArch)\$(XmakeMode)</XmakeConfigFileDir>
+ <XmakeBuildDir Condition="'$(XmakeBuildDir)' == ''">$(XmakeProjectDir)\build</XmakeBuildDir>
+ <XmakeTargetDir Condition="'$(XmakeTargetDir)' == ''">$(XmakeBuildDir)\$(XmakePlat)\$(XmakeArch)\$(XmakeMode)</XmakeTargetDir>
+ <XmakeConfigFileDir Condition="'$(XmakeConfigFileDir)' == ''">$(XmakeBuildDir)\$(XmakePlat)\$(XmakeArch)\$(XmakeMode)</XmakeConfigFileDir>
<XmakeConfigDir Condition="'$(XmakeConfigDir)' == ''">$(XMAKE_CONFIGDIR)</XmakeConfigDir>
<XmakeConfigDir Condition="'$(XmakeConfigDir)' == ''">$(XmakeProjectDir)</XmakeConfigDir>
@@ -171,7 +171,7 @@
<PropertyGroup Label="Path">
<LibraryPath>$(XmakeLinkDirs);$(LibraryPath)</LibraryPath>
<OutDir>$(XmakeTargetDir)\</OutDir>
- <IntDir>$(XmakeBuilDDir)\.vs\$(TargetName)\$(XmakeArch)\$(XmakeMode)\</IntDir>
+ <IntDir>$(XmakeBuildDir)\.vs\$(TargetName)\$(XmakeArch)\$(XmakeMode)\</IntDir>
<SourcePath>$(XmakeSourceDirs);$(SourcePath)</SourcePath>
</PropertyGroup>
diff --git a/xmake/scripts/vsxmake/vsproj/Xmake.targets b/xmake/scripts/vsxmake/vsproj/Xmake.targets
index ec7ea3532..e789e7862 100644
--- a/xmake/scripts/vsxmake/vsproj/Xmake.targets
+++ b/xmake/scripts/vsxmake/vsproj/Xmake.targets
@@ -8,21 +8,21 @@
</ImportGroup>
<PropertyGroup Label="XmakePathsResolve">
- <XmakeBuilDDirResolved>$(XmakeBuilDDir)</XmakeBuilDDirResolved>
+ <XmakeBuildDirResolved>$(XmakeBuildDir)</XmakeBuildDirResolved>
<XmakeTargetDirResolved>$(XmakeTargetDir)</XmakeTargetDirResolved>
<XmakeConfigDirResolved>$(XmakeConfigDir)</XmakeConfigDirResolved>
<XmakeConfigFileDirResolved>$(XmakeConfigFileDir)</XmakeConfigFileDirResolved>
<XmakeRunDirResolved>$(XmakeRunDir)</XmakeRunDirResolved>
<!-- resolve if they are relative paths -->
- <XmakeBuilDDirResolved Condition="!$([System.IO.Path]::IsPathRooted('$(XmakeBuilDDirResolved)'))">$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(XmakeBuilDDirResolved)'))</XmakeBuilDDirResolved>
+ <XmakeBuildDirResolved Condition="!$([System.IO.Path]::IsPathRooted('$(XmakeBuildDirResolved)'))">$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(XmakeBuildDirResolved)'))</XmakeBuildDirResolved>
<XmakeTargetDirResolved Condition="!$([System.IO.Path]::IsPathRooted('$(XmakeTargetDirResolved)'))">$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(XmakeTargetDirResolved)'))</XmakeTargetDirResolved>
<XmakeConfigDirResolved Condition="!$([System.IO.Path]::IsPathRooted('$(XmakeConfigDirResolved)'))">$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(XmakeConfigDirResolved)'))</XmakeConfigDirResolved>
<XmakeConfigFileDirResolved Condition="!$([System.IO.Path]::IsPathRooted('$(XmakeConfigFileDirResolved)'))">$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(XmakeConfigFileDirResolved)'))</XmakeConfigFileDirResolved>
<XmakeRunDirResolved Condition="!$([System.IO.Path]::IsPathRooted('$(XmakeRunDirResolved)'))">$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(XmakeRunDirResolved)'))</XmakeRunDirResolved>
<!-- normalize paths -->
- <XmakeBuilDDirResolved>$([System.IO.Path]::GetFullPath('$(XmakeBuilDDirResolved)/'))</XmakeBuilDDirResolved>
+ <XmakeBuildDirResolved>$([System.IO.Path]::GetFullPath('$(XmakeBuildDirResolved)/'))</XmakeBuildDirResolved>
<XmakeTargetDirResolved>$([System.IO.Path]::GetFullPath('$(XmakeTargetDirResolved)/'))</XmakeTargetDirResolved>
<XmakeConfigDirResolved>$([System.IO.Path]::GetFullPath('$(XmakeConfigDirResolved)/'))</XmakeConfigDirResolved>
<XmakeConfigFileDirResolved>$([System.IO.Path]::GetFullPath('$(XmakeConfigFileDirResolved)/'))</XmakeConfigFileDirResolved>
@@ -44,11 +44,13 @@
<_XmakeCommonFlags Condition="$(XmakeDiagnosis)">-D $(_XmakeCommonFlags.Trim())</_XmakeCommonFlags>
<_XmakeCommonFlags>-y $(_XmakeCommonFlags.Trim()) $(_XmakeProjectFlag)</_XmakeCommonFlags>
- <_XmakeOutFlag>-o "$([MSBuild]::MakeRelative('$(XmakeProjectDirResolved)', '$(XmakeBuilDDirResolved)').TrimEnd('\').TrimEnd('/'))"</_XmakeOutFlag>
+ <_XmakeOutFlag>-o "$([MSBuild]::MakeRelative('$(XmakeProjectDirResolved)', '$(XmakeBuildDirResolved)').TrimEnd('\').TrimEnd('/'))"</_XmakeOutFlag>
<_XmakeConfigFlags>$(XmakeConfigFlags.Trim())</_XmakeConfigFlags>
<_XmakeConfigFlags>-p $(XmakePlat) -m $(XmakeMode) -a $(XmakeArch) $(_XmakeOutFlag) $(_XmakeConfigFlags.Trim())</_XmakeConfigFlags>
+ <_XmakeBuildFlags>$(XmakeBuildFlags.Trim())</_XmakeBuildFlags>
+
<_XmakeBuildFileFlags>$(_XmakeBuildFlags.Trim())</_XmakeBuildFileFlags>
<_XmakeBuildFileFlags Condition="$(XmakeRebuildFile)">$(_XmakeBuildFileFlags.Trim()) -r</_XmakeBuildFileFlags>
@@ -156,7 +158,7 @@ MSBuild Properties:
XmakeProgramFile: $(XmakeProgramFile)
XmakeProjectDir: $(XmakeProjectDir)
XmakeScriptDir: $(XmakeScriptDir)
- XmakeBuilDDir: $(XmakeBuilDDir)
+ XmakeBuildDir: $(XmakeBuildDir)
XmakeTargetDir: $(XmakeTargetDir)
XmakeConfigDir: $(XmakeConfigDir)
XmakeConfigFileDir: $(XmakeConfigFileDir)
@@ -166,7 +168,7 @@ MSBuild Properties:
XmakeProgramFile: $(XmakeProgramFileResolved)
XmakeProjectDir: $(XmakeProjectDirResolved)
XmakeScriptDir: $(XmakeScriptDirResolved)
- XmakeBuilDDir: $(XmakeBuilDDirResolved)
+ XmakeBuildDir: $(XmakeBuildDirResolved)
XmakeTargetDir: $(XmakeTargetDirResolved)
XmakeConfigDir: $(XmakeConfigDirResolved)
XmakeConfigFileDir: $(XmakeConfigFileDirResolved)
diff --git a/xmake/scripts/vsxmake/vsproj/Xmake.xml b/xmake/scripts/vsxmake/vsproj/Xmake.xml
index 3f5600ba6..9bccf1b28 100644
--- a/xmake/scripts/vsxmake/vsproj/Xmake.xml
+++ b/xmake/scripts/vsxmake/vsproj/Xmake.xml
@@ -66,7 +66,7 @@
Description="Set environment XMAKE_CONFIGDIR for xmake tasks"
Subtype="folder" />
<StringProperty
- Name="XmakeBuilDDir"
+ Name="XmakeBuildDir"
DisplayName="Build dir"
Category="Paths"
Description="Set output dir for xmake tasks"
diff --git a/xmake/scripts/vsxmake/vsproj/templates/Xmake.Custom.props b/xmake/scripts/vsxmake/vsproj/templates/Xmake.Custom.props
index 22e84fc46..00d471bc8 100644
--- a/xmake/scripts/vsxmake/vsproj/templates/Xmake.Custom.props
+++ b/xmake/scripts/vsxmake/vsproj/templates/Xmake.Custom.props
@@ -9,7 +9,7 @@
<!-- <XmakeConfigDir Condition="'$(XmakeMode)|$(XmakeArch)' == 'release|x86'">$(XmakeProjectDir)\.xmake</XmakeConfigDir> -->
<!-- set output dir for xmake tasks -->
- <!-- <XmakeBuilDDir>$(XmakeProjectDir)\build</XmakeBuilDDir> -->
+ <!-- <XmakeBuildDir>$(XmakeProjectDir)\build</XmakeBuildDir> -->
</PropertyGroup>
<PropertyGroup Label="XmakeFlags">
diff --git a/xmake/scripts/vsxmake/vsproj/templates/csproj/#target#.csproj b/xmake/scripts/vsxmake/vsproj/templates/csproj/#target#.csproj
new file mode 100644
index 000000000..7074a136d
--- /dev/null
+++ b/xmake/scripts/vsxmake/vsproj/templates/csproj/#target#.csproj
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+#xmake_info#
+
+ This file is auto generated by xmake.
+
+ Please DO NOT EDIT since all your modification will lost after re-generation.
+ If you would like to have any customization,
+ edit Xmake.Custom.props and Xmake.Custom.targets instead.
+-->
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+#Import(ProjectConfiguration)#
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{#target_id#}</ProjectGuid>
+ <Configuration Condition="'$(Configuration)' == ''">release</Configuration>
+ <Platform Condition="'$(Platform)' == ''">AnyCPU</Platform>
+ <XmakeScriptDir>#scriptdir#</XmakeScriptDir>
+ <XmakeProjectDir>#projectdir#</XmakeProjectDir>
+ <XmakeProjectFile>#projectfile#</XmakeProjectFile>
+ <XmakeTarget>#targetname#</XmakeTarget>
+ </PropertyGroup>
+ <PropertyGroup Label="XmakeProgram">
+ <XmakeProgramDir Condition="'$(XmakeProgramDir)' == ''">$(XMAKE_PROGRAM_DIR)</XmakeProgramDir>
+ <XmakeProgramDir Condition="'$(XmakeProgramDir)' == ''">#programdir#</XmakeProgramDir>
+ <XmakeProgramFile Condition="'$(XmakeProgramFile)' == ''">$(XMAKE_PROGRAM_FILE)</XmakeProgramFile>
+ <XmakeProgramFile Condition="'$(XmakeProgramFile)' == ''">#programfile#</XmakeProgramFile>
+ </PropertyGroup>
+ <Import Project="$(XmakeProgramDir)\scripts\vsxmake\vsproj\Xmake.Defaults.props" />
+#Import(XmakeConfig)#
+#Import(XmakePath)#
+ <PropertyGroup>
+ <OutputType Condition="'$(XmakeKind)' == 'binary'">Exe</OutputType>
+ <OutputType Condition="'$(XmakeKind)' == 'shared'">Library</OutputType>
+ <OutputType Condition="'$(XmakeKind)' == 'static'">Library</OutputType>
+ <OutputType Condition="'$(OutputType)' == ''">Library</OutputType>
+ <AssemblyName>$(XmakeBasename)</AssemblyName>
+ <RootNamespace>#targetname#</RootNamespace>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <ItemGroup>
+#Import(File.cs)#
+ </ItemGroup>
+ <!-- <ItemGroup>
+#Import(ProjectRef)#
+ </ItemGroup> -->
+ <Import Project="$(XmakeProgramDir)\scripts\vsxmake\vsproj\Xmake.CSharp.targets" />
+</Project>
diff --git a/xmake/scripts/vsxmake/vsproj/templates/csproj/File.cs(filecs) b/xmake/scripts/vsxmake/vsproj/templates/csproj/File.cs(filecs)
new file mode 100644
index 000000000..f1f9c063a
--- /dev/null
+++ b/xmake/scripts/vsxmake/vsproj/templates/csproj/File.cs(filecs)
@@ -0,0 +1 @@
+ <Compile Include="#path#" />
diff --git a/xmake/scripts/vsxmake/vsproj/templates/csproj/ProjectConfiguration(mode,arch) b/xmake/scripts/vsxmake/vsproj/templates/csproj/ProjectConfiguration(mode,arch)
new file mode 100644
index 000000000..d6956bf15
--- /dev/null
+++ b/xmake/scripts/vsxmake/vsproj/templates/csproj/ProjectConfiguration(mode,arch)
@@ -0,0 +1,4 @@
+ <ProjectConfiguration Include="#mode#|#vsarch#">
+ <Configuration>#mode#</Configuration>
+ <Platform>#vsarch#</Platform>
+ </ProjectConfiguration>
diff --git a/xmake/scripts/vsxmake/vsproj/templates/csproj/ProjectRef(dep) b/xmake/scripts/vsxmake/vsproj/templates/csproj/ProjectRef(dep)
new file mode 100644
index 000000000..88c9645b2
--- /dev/null
+++ b/xmake/scripts/vsxmake/vsproj/templates/csproj/ProjectRef(dep)
@@ -0,0 +1,3 @@
+ <ProjectReference Include="..\#targetname_inpath#\#targetname_inpath#.#projext#">
+ <Project>{#target_id#}</Project>
+ </ProjectReference>
diff --git a/xmake/scripts/vsxmake/vsproj/templates/csproj/XmakeConfig(mode,arch) b/xmake/scripts/vsxmake/vsproj/templates/csproj/XmakeConfig(mode,arch)
new file mode 100644
index 000000000..864300fd7
--- /dev/null
+++ b/xmake/scripts/vsxmake/vsproj/templates/csproj/XmakeConfig(mode,arch)
@@ -0,0 +1,14 @@
+ <PropertyGroup Label="XmakeConfig" Condition="'$(Configuration)|$(Platform)'=='#mode#|#vsarch#'">
+ <XmakeBasename>#basename#</XmakeBasename>
+ <XmakeFilename>#filename#</XmakeFilename>
+ <XmakeMode>#mode#</XmakeMode>
+ <XmakePlat>#plat#</XmakePlat>
+ <XmakeArch>#arch#</XmakeArch>
+ <XmakeKind>#kind#</XmakeKind>
+ <XmakeDefault>#default#</XmakeDefault>
+ <XmakeDefines>#defines#</XmakeDefines>
+ <XmakeLanguages>#languages#</XmakeLanguages>
+ <XmakeRunEnvs>#runenvs#</XmakeRunEnvs>
+ <XmakeRunArgs>#runargs#</XmakeRunArgs>
+ <XmakeConfigFlags>#configflags#</XmakeConfigFlags>
+ </PropertyGroup>
diff --git a/xmake/scripts/vsxmake/vsproj/templates/csproj/XmakePath(mode,arch) b/xmake/scripts/vsxmake/vsproj/templates/csproj/XmakePath(mode,arch)
new file mode 100644
index 000000000..7e423ee00
--- /dev/null
+++ b/xmake/scripts/vsxmake/vsproj/templates/csproj/XmakePath(mode,arch)
@@ -0,0 +1,7 @@
+ <PropertyGroup Label="XmakePath" Condition="'$(Configuration)|$(Platform)'=='#mode#|#vsarch#'">
+ <XmakeBuildDir>#builddir#</XmakeBuildDir>
+ <XmakeConfigDir>#configdir#</XmakeConfigDir>
+ <XmakeConfigFileDir>#configfiledir#</XmakeConfigFileDir>
+ <XmakeTargetDir>#targetdir#</XmakeTargetDir>
+ <XmakeRunDir>#rundir#</XmakeRunDir>
+ </PropertyGroup>
diff --git a/xmake/scripts/vsxmake/vsproj/templates/sln/Project(target) b/xmake/scripts/vsxmake/vsproj/templates/sln/Project(target)
index e53697651..96fa75078 100644
--- a/xmake/scripts/vsxmake/vsproj/templates/sln/Project(target)
+++ b/xmake/scripts/vsxmake/vsproj/templates/sln/Project(target)
@@ -1,2 +1,2 @@
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "#targetname#", "#vcxprojdir_relative_sln#\#targetname_inpath#.vcxproj", "{#target_id#}"
+Project("{#projtypeguid#}") = "#targetname#", "#vcxprojdir_relative_sln#\#targetname_inpath#.#projext#", "{#target_id#}"
EndProject
diff --git a/xmake/scripts/vsxmake/vsproj/templates/vcxproj/XmakePath(mode,arch) b/xmake/scripts/vsxmake/vsproj/templates/vcxproj/XmakePath(mode,arch)
index f724ee28c..7e423ee00 100644
--- a/xmake/scripts/vsxmake/vsproj/templates/vcxproj/XmakePath(mode,arch)
+++ b/xmake/scripts/vsxmake/vsproj/templates/vcxproj/XmakePath(mode,arch)
@@ -1,5 +1,5 @@
<PropertyGroup Label="XmakePath" Condition="'$(Configuration)|$(Platform)'=='#mode#|#vsarch#'">
- <XmakeBuilDDir>#builddir#</XmakeBuilDDir>
+ <XmakeBuildDir>#builddir#</XmakeBuildDir>
<XmakeConfigDir>#configdir#</XmakeConfigDir>
<XmakeConfigFileDir>#configfiledir#</XmakeConfigFileDir>
<XmakeTargetDir>#targetdir#</XmakeTargetDir>