Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce MSBuild tasks programability #9247

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions OrchardCore.sln
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OrchardCore.Roles.Core", "s
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrchardCore.AutoSetup", "src\OrchardCore.Modules\OrchardCore.AutoSetup\OrchardCore.AutoSetup.csproj", "{1E76C17C-099A-4E6D-BC26-E93CBA4D0BD6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OrchardCore.Build", "src\OrchardCore.Build\OrchardCore.Build.csproj", "{99DE2D49-DF0C-4CE9-B83B-354755A2B6B3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -1084,6 +1086,10 @@ Global
{1E76C17C-099A-4E6D-BC26-E93CBA4D0BD6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1E76C17C-099A-4E6D-BC26-E93CBA4D0BD6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1E76C17C-099A-4E6D-BC26-E93CBA4D0BD6}.Release|Any CPU.Build.0 = Release|Any CPU
{99DE2D49-DF0C-4CE9-B83B-354755A2B6B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{99DE2D49-DF0C-4CE9-B83B-354755A2B6B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{99DE2D49-DF0C-4CE9-B83B-354755A2B6B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{99DE2D49-DF0C-4CE9-B83B-354755A2B6B3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -1273,6 +1279,7 @@ Global
{1D0144D0-9E6D-441B-A393-B62F6DC8E97E} = {90030E85-0C4F-456F-B879-443E8A3F220D}
{15E0499A-815D-4E98-B1E4-1C9D7B3D1461} = {F23AC6C2-DE44-4699-999D-3C478EF3D691}
{1E76C17C-099A-4E6D-BC26-E93CBA4D0BD6} = {A066395F-6F73-45DC-B5A6-B4E306110DCE}
{99DE2D49-DF0C-4CE9-B83B-354755A2B6B3} = {184139CF-C4AB-4FBE-AE19-54C8B3FE5C5E}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {46A1D25A-78D1-4476-9CBF-25B75E296341}
Expand Down
30 changes: 30 additions & 0 deletions src/OrchardCore.Build/CreateWebRootFolderTask.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.IO;
using Microsoft.Build.Utilities;

namespace OrchardCore.Build
{
public class CreateWebRootFolderTask : Task
{
private const string WebRootFolderName = "wwwroot";

public override bool Execute()
{
var placeholderFileName = ".placeholder";
var placeholderFilePath = Path.Combine(WebRootFolderName, placeholderFileName);
if (File.Exists(placeholderFilePath))
{
Log.LogWarning("Web Root folder isn't created.");
}
else
{
Directory.CreateDirectory(WebRootFolderName);
File.WriteAllText(placeholderFilePath, String.Empty);

Log.LogWarning("Web Root folder is created.");
}

return true;
}
}
}
13 changes: 13 additions & 0 deletions src/OrchardCore.Build/OrchardCore.Build.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<Import Project="Dependencies.props" />

<PropertyGroup>
<TargetFrameworks>$(AspNetCoreTargetFrameworks)</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="16.9.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<PropertyGroup>
<SolutionDir>$([System.IO.Path]::GetDirectoryName($(MSBuildProjectDirectory)))</SolutionDir>
</PropertyGroup>

<UsingTask AssemblyFile="$(SolutionDir)\src\OrchardCore.Build\bin\Debug\$(TargetFramework)\OrchardCore.Build.dll" TaskName="CreateWebRootFolderTask" />

<ItemGroup>
<Compile Remove="App_Data\**;Localization\**" />
<Content Remove="App_Data\**;Localization\**" />
Expand All @@ -13,8 +19,8 @@
</ResolvedFileToPublish>
</ItemGroup>

<Target Name="MakeWebRootFolder" BeforeTargets="MakeLocalizationFolder" Condition="!Exists('wwwroot/.placeholder')">
<WriteLinesToFile Lines="" Encoding="Unicode" File="wwwroot/.placeholder" />
<Target Name="MakeWebRootFolder" BeforeTargets="MakeLocalizationFolder">
<CreateWebRootFolderTask />
</Target>

<Target Name="MakeLocalizationFolder" BeforeTargets="Build" Condition="!Exists('Localization/.placeholder')">
Expand Down