<Project Sdk="Microsoft.NET.Sdk.Razor">

	<PropertyGroup>
		<TargetFramework>net7.0</TargetFramework>
		<Nullable>enable</Nullable>
		<ImplicitUsings>enable</ImplicitUsings>
		<RootNamespace>Connected</RootNamespace>
	</PropertyGroup>

	<ItemGroup>
		<None Include="compilerconfig.json" />
		<None Include="ComponentsN\ToggleButton.razor" />
		<None Include="ComponentsN\Button.razor" />
		<None Include="ComponentsN\Glyph.razor" />
		<None Include="ComponentsN\Link.razor" />
		<None Include="ComponentsN\InputDate.razor" />
		<None Include="ComponentsN\InputNumber.razor" />
		<None Include="ComponentsN\InputText.razor" />
	</ItemGroup>


	<ItemGroup>
		<SupportedPlatform Include="browser" />
	</ItemGroup>

	<ItemGroup>
		<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.2" />
	</ItemGroup>

	<ItemGroup>
	  <Folder Include="wwwroot\" />
	</ItemGroup>
	<!--<Target Name="CompileStaticAssets" AfterTargets="AfterBuild">
		<Exec Command="webcompiler -r wwwroot" StandardOutputImportance="high" />
	</Target>-->

	<Target Name="ToolRestore">
		<Exec Command="dotnet tool restore" StandardOutputImportance="high" />
	</Target>

	<!--combine js files
	<Target Name="CombineJS">
		<CreateItem Include="./TScripts/*.js" Exclude="./TScripts/*.min.js">
			<Output TaskParameter="Include" ItemName="jsFilesToCombine" />
		</CreateItem>
		<ReadLinesFromFile File="%(jsFilesToCombine.FullPath)">
			<Output TaskParameter="Lines" ItemName="jsLines" />
		</ReadLinesFromFile>
		<WriteLinesToFile File="./TScripts/combined/Connected.Components.js" Lines="@(jsLines)" Overwrite="true" />
	</Target>

	<Target Name="WebCompiler" DependsOnTargets="ToolRestore;CombineJS">-->
	<Target Name="WebCompiler" DependsOnTargets="ToolRestore;">
		<!--compile and minify scss-->
		<Exec Command="dotnet webcompiler ./Styles/Connected.Components.scss -c excubowebcompiler.json" StandardOutputImportance="high" StandardErrorImportance="high" />
		<!--minify js-->
		<Exec Command="dotnet webcompiler ./TScripts/combined/Connected.Components.js -c excubowebcompiler.json" StandardOutputImportance="high" StandardErrorImportance="high" />
	</Target>

	<Target Name="IncludeGeneratedStaticFiles" DependsOnTargets="WebCompiler" BeforeTargets="BeforeBuild">
		<Error Condition="!Exists('$(MSBuildProjectDirectory)/wwwroot/Connected.Components.min.css')" Text="Missing Connected.Components.min.css in wwwroot" />
		<Error Condition="!Exists('$(MSBuildProjectDirectory)/wwwroot/Connected.Components.min.js')" Text="Missing Connected.Components.min.js in wwwroot" />
		<ItemGroup>
			<!--Include without duplication-->
			<_NewCompiledCssFiles Include="wwwroot\Connected.Components.min.css" Exclude="@(Content)" />
			<_NewCompiledJsFiles Include="wwwroot\Connected.Components.min.js" Exclude="@(Content)" />
			<Content Include="@(_NewCompiledCssFiles)" />
			<Content Include="@(_NewCompiledJsFiles)" />
		</ItemGroup>
	</Target>

	<Target Name="Delete sass/js compiler artifacts" AfterTargets="AfterBuild">
		<Delete Files="./Styles/Connected.Components.css" />
		<Delete Files="./Styles/Connected.Components.min.css" />
		<Delete Files="./TScripts/combined/Connected.Components.js" />
		<Delete Files="./TScripts/combined/Connected.Components.min.js" />
	</Target>
	
	<!--Dont Include in build output-->
	<ItemGroup>
		<Content Remove="compilerconfig.json" />
		<Content Remove="excubowebcompiler.json" />
		<Content Remove="wwwroot/DoNotRemove.txt" />
		<Compile Remove="ComponentsN\**" />
		<!--macOS hidden file (causes problems with dotnet pack)-->
		<Content Remove="**/*/.DS_Store" />
		<Content Remove="ComponentsN\**" />
	</ItemGroup>

	<ItemGroup>
		<!--For automatic compile on save of the scss use
    cd ./src/MudBlazor
    dotnet watch webcompiler ./Styles/MudBlazor.scss -c excubowebcompiler.json
    -->
		<Watch Include="**/*.scss" />
	</ItemGroup>

	<ItemGroup>
	  <EmbeddedResource Remove="ComponentsN\**" />
	  <None Remove="ComponentsN\**" />
	  <Watch Remove="ComponentsN\**" />
	</ItemGroup>

	<ItemGroup>
	  <Watch Remove="Styles\Connected.Components.scss" />
	</ItemGroup>

	<ItemGroup>
	  <Content Include=".config\dotnet-tools.json" />
	</ItemGroup>
</Project>
