Visual Studio C# projects can now link to external files

This commit is contained in:
Jason Perkins 2013-03-10 15:56:56 -04:00
parent b10f1b5b60
commit 2d5a5910e6
3 changed files with 40 additions and 19 deletions

View File

@ -23,6 +23,7 @@
* Added forceinclude() to specify forced include files * Added forceinclude() to specify forced include files
* Visual Studio C# projects now support architectures * Visual Studio C# projects now support architectures
* Visual Studio C# projects now support pre- and post-build commands * Visual Studio C# projects now support pre- and post-build commands
* Visual Studio C# projects can now link to external files
* Added NoImplicitLink flag to force explicit linking from Visual Studio * Added NoImplicitLink flag to force explicit linking from Visual Studio
* Decoupled VS2010 smaller type checks (/RTCc) from extra warnings (/W4) * Decoupled VS2010 smaller type checks (/RTCc) from extra warnings (/W4)
* Added NoRuntimeChecks flag to disable Visual Studio default checks * Added NoRuntimeChecks flag to disable Visual Studio default checks

View File

@ -139,12 +139,17 @@
local action = dotnet.getbuildaction(filecfg) local action = dotnet.getbuildaction(filecfg)
local fname = path.translate(node.relpath) local fname = path.translate(node.relpath)
local external = node.relpath:startswith("../")
local elements, dependency = cs2005.getrelated(prj, filecfg, action) local elements, dependency = cs2005.getrelated(prj, filecfg, action)
if elements == "None" then if elements == "None" and not external then
_p(2,'<%s Include="%s" />', action, fname) _p(2,'<%s Include="%s" />', action, fname)
else else
_p(2,'<%s Include="%s">', action, fname) _p(2,'<%s Include="%s">', action, fname)
if external then
_p(3,'<Link>%s</Link>', path.getname(fname))
end
if elements == "AutoGen" then if elements == "AutoGen" then
_p(3,'<AutoGen>True</AutoGen>') _p(3,'<AutoGen>True</AutoGen>')
elseif elements == "AutoGenerated" then elseif elements == "AutoGenerated" then
@ -153,7 +158,7 @@
_x(3,'<LastGenOutput>%s.Designer.cs</LastGenOutput>', path.getbasename(node.name)) _x(3,'<LastGenOutput>%s.Designer.cs</LastGenOutput>', path.getbasename(node.name))
elseif elements == "PreserveNewest" then elseif elements == "PreserveNewest" then
_p(3,'<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>') _p(3,'<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>')
elseif elements then elseif elements ~= "None" then
_p(3,'<SubType>%s</SubType>', elements) _p(3,'<SubType>%s</SubType>', elements)
end end
if dependency then if dependency then

View File

@ -46,20 +46,6 @@
end end
--
-- The relative path to the file is correct for files that live outside
-- the project's folder.
--
function suite.filesUseRelativePath_onOutOfTreePath()
files { "../Src/Hello.cs" }
prepare()
test.capture [[
<Compile Include="..\Src\Hello.cs" />
]]
end
-- --
-- Test file dependencies -- Test file dependencies
-- --
@ -96,3 +82,32 @@
</Content> </Content>
]] ]]
end end
--
-- Files that exist outside the project folder should be added as
-- links, with a relative path. Weird but true.
--
function suite.usesLinks_onExternalSourceFile()
files { "../Src/Hello.cs" }
prepare()
test.capture [[
<Compile Include="..\Src\Hello.cs">
<Link>Hello.cs</Link>
</Compile>
]]
end
function suite.copyAction_onExternalResource()
files { "../Resources/Hello.txt" }
configuration "**.txt"
buildaction "Copy"
prepare()
test.capture [[
<Content Include="..\Resources\Hello.txt">
<Link>Hello.txt</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
]]
end