-- -- vs2002_csproj.lua -- Generate a Visual Studio 2002/2003 C# project. -- Copyright (c) 2009 Jason Perkins and the Premake project -- -- -- Figure out what elements a particular file need in its item block, -- based on its build action and any related files in the project. -- local function getelements(prj, action, fname) if action == "Compile" and fname:endswith(".cs") then return "SubTypeCode" end if action == "EmbeddedResource" and fname:endswith(".resx") then -- is there a matching *.cs file? local basename = fname:sub(1, -6) local testname = path.getname(basename .. ".cs") if premake.findfile(prj, testname) then return "Dependency", testname end end return "None" end function premake.vs2002_csproj(prj) io.eol = "\r\n" _p('') _p(1,'') _p(2,'') -- Write out project-wide settings _p(3,'') -- Write out configuration blocks for cfg in premake.eachconfig(prj) do _p(4,'') end _p(3,'') -- List assembly references _p(3,'') for _, ref in ipairs(premake.getlinks(prj, "siblings", "object")) do _p(4,'') end for _, linkname in ipairs(premake.getlinks(prj, "system", "fullpath")) do _p(4,'') end _p(3,'') _p(2,'') -- List source files _p(2,'') _p(3,'') for fcfg in premake.eachfile(prj) do local action = premake.dotnet.getbuildaction(fcfg) local fname = path.translate(premake.esc(fcfg.name), "\\") local elements, dependency = getelements(prj, action, fcfg.name) _p(4,'') end _p(3,'') _p(2,'') _p(1,'') _p('') end