<Project
	DefaultTargets="Clean;Compile"
	NOTNEEDED_ToolsVersion="3.5"
	xmlns="http://schemas.microsoft.com/developer/msbuild/2003" 
>
<!--
URLref: [MSBuild Overview @ Philip Hendry's Blog] http://philiphendry.wordpress.com/tech-notes/msbuild/
URLref: [MSBuild CSC target] http://msdn.microsoft.com/en-us/library/s5c8athz.aspx
URLref: [Target Specific NET framworks] http://msdn.microsoft.com/en-us/library/bb383796.aspx
URLref: http://msdn.microsoft.com/en-us/library/bcxfsh87.aspx
URLref: [GenerateApplicationManifest Task] http://msdn.microsoft.com/en-us/library/6wc2ccdc.aspx
-->

<PropertyGroup>
	<DEBUG></DEBUG>	<!-- [ '', 'full', 'pdbonly' ] -->
</PropertyGroup>

<ItemGroup>
	<CSFile Include="*.cs" Exclude="t-wrap*;*.o.cs"/>
</ItemGroup>

<ItemGroup>
	<REFFiles Include="./lib/*.dll"/>
</ItemGroup>
<ItemGroup>
	<RESFiles_ Include="./lib/Interop.MSScriptControl.dll"/>
</ItemGroup>

<ItemGroup>
	<RESFiles Include="@(RESFiles_)">
		<LogicalName>@(RESFiles_->'%(filename)%(extension)')</LogicalName>
	</RESFiles>
</ItemGroup>

<ItemGroup>
	<DELFiles Include="*.exe"/>
	<DELFiles Include="*.pdb"/>
	<DELFiles Include="*.bak"/>
	<!--DELFiles Include="README"/-->
</ItemGroup>

<PropertyGroup>
	<WindowsSdkDir Condition="'$(WindowsSdkDir)' == ''">$(Registry:HKEY_CURRENT_USER\SOFTWARE\Microsoft\Microsoft SDKs\Windows@CurrentInstallFolder)</WindowsSdkDir>
	<WindowsSdkDir Condition="'$(WindowsSdkDir)' == ''">$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows@CurrentInstallFolder)</WindowsSdkDir>
</PropertyGroup>	

<Target Name="Compile" Inputs="@(CSFile)" Outputs="%(filename).EXE">
	<!-- Run the Visual C# compilation using input files of type CSFile -->
	<!--CSC Sources="@(CSFile)" OutputAssembly = "$(appname).exe"-->

	<!--Message Text="RESFiles_ = `@(RESFiles_)` => @(RESFiles_->'%(LogicalName)')"/-->
	<!--Message Text="RESFiles = `@(RESFiles)` => @(RESFiles->'%(LogicalName)')"/-->
	
	<!--ResolveAssemblyReference Assemblies="Interop.MSScriptControl" SearchPaths="{AssemblyFolders}"/-->
	<!--ResolveAssemblyReference Assemblies="Microsoft.VC90.CRT" SearchPaths="{AssemblyFolders}"/-->

	<CSC Sources="%(CSFile.Identity)" OutputAssembly="@(CSFile->'%(filename).EXE')" References="@(REFFiles)" Resources="@(RESFiles)" NoLogo="true" Optimize="true" DebugType="$(DEBUG)" WarningLevel="4" >
		<Output TaskParameter = "OutputAssembly" ItemName = "EXEFile" /><!-- ## Set the OutputAssembly attribute of the CSC task to the name of the executable file that is created -->
	</CSC>

	<!--	
	<GenerateApplicationManifest
	            AssemblyName="@(CSFile->'%(filename).EXE')"
	            AssemblyVersion="1.0.0.0"
	            EntryPoint="@(CSFile->'%(filename).EXE')"
	            OutputManifest="@(CSFile->'%(filename).EXE.manifest')">
	            <Output
	                ItemName="ApplicationManifest"
	                TaskParameter="OutputManifest"/>
	</GenerateApplicationManifest>
	-->

	<!-- HKEY_CURRENT_USER\Software\Microsoft\Microsoft SDKs\Windows\CurrentInstallFolder = "C:\Program Files\Microsoft SDKs\Windows\v6.1\" -->
	<!-- HKEY_CURRENT_USER\Software\Microsoft\Microsoft SDKs\Windows\CurrentVersion = "v6.1" -->
	<!-- HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\CurrentInstallFolder = "C:\Program Files\Microsoft SDKs\Windows\v6.1\" -->
	<!-- HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\CurrentVersion = "v6.1" -->
	<!-- HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\ProductVersion = "v6.1" -->
	
	<!--Exec Command='"$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows@CurrentInstallFolder)/bin/mt.EXE" /nologo /manifest ./manifest/Microsoft.VC90.CRT.manifest ./manifest/Security.Standard.manifest /outputresource:"%(EXEFile.Identity)";#1'/-->
	<!--Exec Command='"$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows@CurrentInstallFolder)/bin/mt.EXE" /nologo /manifest "@(ApplicationManifest)" /outputresource:"@(EXEFile)";#1'/--> 

	<!-- ?? NOT needed with SDKv2.0? which is good since mt.exe isn't in the default NET files in Vista? -->
	<!-- ?? NOT needed with 3.5 now ** ?? why was it required before? -->
	<!--Exec Command='"$(WindowsSdkDir)/bin/mt.EXE" /nologo /manifest ./manifest/Microsoft.VC90.CRT.manifest ./manifest/Security.Standard.manifest /outputresource:"%(EXEFile.Identity)";#1'/-->

	<!-- Log the file name of the output file -->
	<!--Message Text="The output file(s): %(EXEFile.Identity)"/-->
</Target>

<Target Name="Clean">
	<Delete Files="@(DELFiles)">
		<Output TaskParameter = "DeletedFiles" ItemName = "DeletedFiles" />
	</Delete>
</Target>

<Target Name="Readme" Inputs="@(CSFile)" Outputs="README">
	<!-- TODO: make more robust for multiple file CS compiles -->
	<!-- TODO: make more robust for missing perl -->
	<Exec Command='pod2readme @(CSFile)' />
</Target>

</Project>