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

Compatibility with .NET CLI version of MsBuild #330

Merged
merged 6 commits into from
Oct 12, 2017
Merged
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
6 changes: 4 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ install:

before_build:
- ps: Vsix-IncrementVsixVersion | Vsix-UpdateBuildVersion
- ps: Vsix-IncrementNuspecVersion .\src\WebCompiler\MSBuild\*.nuspec
- ps: Vsix-TokenReplacement src\WebCompilerVsix\WebCompilerPackage.cs 'Version = "([0-9\\.]+)"' 'Version = "{version}"'
- ps: Vsix-TokenReplacement src\WebCompiler\Compile\CompilerService.cs 'Version = "([0-9\\.]+)"' 'Version = "{version}"'

build_script:
- nuget restore -Verbosity quiet
- msbuild /p:configuration=Release /p:DeployExtension=false /p:ZipPackageCompressionLevel=normal /v:m
- dotnet restore src\WebCompiler\
- msbuild .\src\WebCompilerVsix\WebCompilerVsix.csproj /p:configuration=Release /p:DeployExtension=false /p:ZipPackageCompressionLevel=normal /v:m
- msbuild .\src\WebCompilerTest\WebCompilerTest.csproj /p:configuration=Release /v:m
- ps: dotnet pack src\WebCompiler\ -c Release "/p:Version=${env:APPVEYOR_BUILD_VERSION}"

after_test:
- ps: Vsix-PushArtifacts
Expand Down
24 changes: 0 additions & 24 deletions src/WebCompiler/MSBuild/BuildWebCompiler.nuspec

This file was deleted.

14 changes: 5 additions & 9 deletions src/WebCompiler/MSBuild/BuildWebCompiler.targets
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<PropertyGroup>
<BuildDependsOn>
WebCompile;
$(BuildDependsOn)
</BuildDependsOn>
<_WebCompilerTaskAssembly Condition="'$(MSBuildRuntimeType)' == 'Core'">..\tools\netstandard2.0\WebCompiler.dll</_WebCompilerTaskAssembly>
<_WebCompilerTaskAssembly Condition="'$(MSBuildRuntimeType)' != 'Core'">..\tools\net46\WebCompiler.exe</_WebCompilerTaskAssembly>
</PropertyGroup>

<UsingTask AssemblyFile="..\tools\WebCompiler.exe" TaskName="WebCompiler.CompilerBuildTask"/>
<UsingTask AssemblyFile="..\tools\WebCompiler.exe" TaskName="WebCompiler.CompilerCleanTask"/>
<UsingTask AssemblyFile="$(_WebCompilerTaskAssembly)" TaskName="WebCompiler.CompilerBuildTask"/>
<UsingTask AssemblyFile="$(_WebCompilerTaskAssembly)" TaskName="WebCompiler.CompilerCleanTask"/>

<Target Name="WebCompile" BeforeTargets="BundleMinify" Condition="'$(RunWebCompiler)' != 'False'">
<Target Name="WebCompile" BeforeTargets="BundleMinify;BeforeCompile" Condition="'$(RunWebCompiler)' != 'False'">
<WebCompiler.CompilerBuildTask FileName="$(MSBuildProjectDirectory)\compilerconfig.json" />
</Target>
<Target Name="WebCompileClean" AfterTargets="CoreClean" Condition="'$(RunWebCompiler)' != 'False'">
<WebCompiler.CompilerCleanTask FileName="$(MSBuildProjectDirectory)\compilerconfig.json" />
</Target>

</Project>
4 changes: 2 additions & 2 deletions src/WebCompiler/Minify/CssOptions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using Microsoft.Ajax.Utilities;
using NUglify;
using NUglify.Css;

namespace WebCompiler
{
Expand Down
11 changes: 5 additions & 6 deletions src/WebCompiler/Minify/FileMinifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.IO.Compression;
using System.Text;
using System.Text.RegularExpressions;
using Microsoft.Ajax.Utilities;
using NUglify;

namespace WebCompiler
{
Expand Down Expand Up @@ -37,12 +37,11 @@ private static MinificationResult MinifyJavaScript(Config config, string file)
if (config.Minify.ContainsKey("enabled") && config.Minify["enabled"].ToString().Equals("false", StringComparison.OrdinalIgnoreCase))
return null;

var minifier = new Minifier();

string minFile = GetMinFileName(file);
string mapFile = minFile + ".map";

string result = minifier.MinifyJavaScript(content, settings);
var minifiedJs = Uglify.Js(content, settings);
string result = minifiedJs.Code;

bool containsChanges = FileHelpers.HasFileContentChanged(minFile, result);

Expand Down Expand Up @@ -71,12 +70,12 @@ private static MinificationResult MinifyCss(Config config, string file)
if (config.Minify.ContainsKey("enabled") && config.Minify["enabled"].ToString().Equals("false", StringComparison.OrdinalIgnoreCase))
return null;

var minifier = new Minifier();

// Remove control characters which AjaxMin can't handle
content = Regex.Replace(content, @"[\u0000-\u0009\u000B-\u000C\u000E-\u001F]", string.Empty);
var minifiedCss = Uglify.Css(content, settings);

string result = minifier.MinifyStyleSheet(content, settings);
string result = minifiedCss.Code;
string minFile = GetMinFileName(file);
bool containsChanges = FileHelpers.HasFileContentChanged(minFile, result);

Expand Down
3 changes: 2 additions & 1 deletion src/WebCompiler/Minify/JavaScriptOptions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using Microsoft.Ajax.Utilities;
using NUglify;
using NUglify.JavaScript;

namespace WebCompiler
{
Expand Down
152 changes: 33 additions & 119 deletions src/WebCompiler/WebCompiler.csproj
Original file line number Diff line number Diff line change
@@ -1,134 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\common.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{B714B5B9-27C4-443C-9517-FE5C5EF46EA2}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>WebCompiler</RootNamespace>
<AssemblyName>WebCompiler</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworks>net46;netstandard2.0;netcoreapp2.0</TargetFrameworks>

<Title>Web Compiler</Title>
<PackageId>BuildWebCompiler</PackageId>

<BuildOutputTargetFolder>tools</BuildOutputTargetFolder>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<NoPackageAnalysis>true</NoPackageAnalysis>
<!-- forces SDK to copy dependencies into build output to make packing easier -->
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\WebCompiler.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\WebCompiler.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<PropertyGroup>
<NoWin32Manifest>true</NoWin32Manifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="AjaxMin, Version=5.14.5506.26196, Culture=neutral, PublicKeyToken=21ef50ce11b5d80f, processorArchitecture=MSIL">
<HintPath>..\..\packages\AjaxMin.5.14.5506.26202\lib\net40\AjaxMin.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Build.Framework" />
<Reference Include="Microsoft.Build.Tasks.v4.0" />
<Reference Include="Microsoft.Build.Utilities.v4.0" />
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Numerics" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Web" />
<Reference Include="System.XML" />
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
<Compile Include="Compile\BaseOptions.cs" />
<Compile Include="Compile\BabelCompiler.cs" />
<Compile Include="Compile\CssRelativePathAdjuster.cs" />
<Compile Include="Compile\IcedCoffeeScriptOptions.cs" />
<Compile Include="Compile\IcedCoffeeScriptCompiler.cs" />
<Compile Include="Compile\CompilerService.cs" />
<Compile Include="Compile\ICompiler.cs" />
<Compile Include="Compile\HandlebarsCompiler.cs" />
<Compile Include="Compile\HandlebarsOptions.cs" />
<Compile Include="Compile\StylusCompiler.cs" />
<Compile Include="Compile\BabelOptions.cs" />
<Compile Include="Compile\StylusOptions.cs" />
<Compile Include="Compile\SassOptions.cs" />
<Compile Include="Compile\LessOptions.cs" />
<Compile Include="Compile\SassCompiler.cs" />
<Compile Include="Config\ConfigProcessedEventArgs.cs" />
<Compile Include="Config\Config.cs" />
<Compile Include="Compile\CompilerError.cs" />
<Compile Include="Compile\CompilerResult.cs" />
<Compile Include="Compile\LessCompiler.cs" />
<Compile Include="Dependencies\Dependencies.cs" />
<Compile Include="Dependencies\DependencyService.cs" />
<Compile Include="Dependencies\DependencyResolverBase.cs" />
<Compile Include="Dependencies\LessDependencyResolver.cs" />
<Compile Include="Dependencies\SassDependencyResolver.cs" />
<Compile Include="Helpers\FileHelpers.cs" />
<Compile Include="Minify\BaseMinifyOptions.cs" />
<Compile Include="Minify\FileMinifier.cs" />
<Compile Include="Minify\CssOptions.cs" />
<Compile Include="Minify\JavaScriptOptions.cs" />
<Compile Include="Minify\MinificationResult.cs" />
<Compile Include="Minify\MinifyFileEventArgs.cs" />
<Compile Include="MSBuild\CompilerCleanTask.cs" />
<Compile Include="MSBuild\CompilerBuildTask.cs" />
<Compile Include="Program.cs" />
<Compile Include="SourceMapEventArgs.cs" />
<Compile Include="Config\CompileFileEventArgs.cs" />
<Compile Include="Config\ConfigHandler.cs" />
<Compile Include="Config\ConfigFileProcessor.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Content Include="MSBuild\*.targets" PackagePath="build\" />
</ItemGroup>
<ItemGroup>
<None Include="MSBuild\BuildWebCompiler.nuspec">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="MSBuild\BuildWebCompiler.targets">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<EmbeddedResource Include="Node\prepare.cmd" />
<EmbeddedResource Include="Node\node.7z" />
<EmbeddedResource Include="Node\node_modules.7z" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Node\7z.dll" />
<EmbeddedResource Include="Node\7z.exe" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>"$(SolutionDir)packages\NuGet.CommandLine.2.8.5\tools\nuget.exe" pack .\msbuild\BuildWebCompiler.nuspec -Verbosity quiet</PostBuildEvent>
</PropertyGroup>
<PropertyGroup>
<PreBuildEvent>"$(SolutionDir)build\build.cmd"</PreBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
<ItemGroup>
<PackageReference Include="Microsoft.Build.Framework" Version="15.1.0-*" PrivateAssets="All" />
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="15.1.0-*" PrivateAssets="All" />
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" PrivateAssets="All" />
<PackageReference Include="NUglify" Version="1.5.5" PrivateAssets="All" />
</ItemGroup>
<Target Name="PrepareNpmDependencies" AfterTargets="Restore">
<Exec Command="..\..\build\build.cmd" />
</Target>
<Target Name="AfterBuild">
<Target Name="PackTaskDependencies" BeforeTargets="GenerateNuspec">
<!--
The include needs to happen after output has been copied to build output folder
but before NuGet generates a nuspec. See https://github.com/NuGet/Home/issues/4704.
-->
<ItemGroup>
<_PackageFiles Include="bin\$(Configuration)\*\Newtonsoft.Json.dll;bin\$(Configuration)\*\NUglify.dll">
<PackagePath>tools\%(RecursiveDir)</PackagePath>
<Visible>false</Visible>
<BuildAction>Content</BuildAction>
</_PackageFiles>
</ItemGroup>
</Target>
-->
</Project>
3 changes: 2 additions & 1 deletion src/WebCompilerTest/Minify/CssOptionsTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using System.IO;
using System.Linq;
using Microsoft.Ajax.Utilities;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NUglify;
using NUglify.Css;
using WebCompiler;

namespace WebCompilerTest.Minify
Expand Down
3 changes: 2 additions & 1 deletion src/WebCompilerTest/Minify/JavaScriptOptionsTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using System.IO;
using System.Linq;
using Microsoft.Ajax.Utilities;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NUglify;
using NUglify.JavaScript;
using WebCompiler;

namespace WebCompilerTest.Minify
Expand Down
6 changes: 3 additions & 3 deletions src/WebCompilerTest/WebCompilerTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="AjaxMin, Version=5.14.5506.26196, Culture=neutral, PublicKeyToken=21ef50ce11b5d80f, processorArchitecture=MSIL">
<HintPath>..\..\packages\AjaxMin.5.14.5506.26202\lib\net40\AjaxMin.dll</HintPath>
<Private>True</Private>
<Reference Include="NUglify, Version=1.5.5.0, Culture=neutral, PublicKeyToken=15bc7810aec21b5e, processorArchitecture=MSIL">
<HintPath>..\..\packages\NUglify.1.5.5\lib\net40\NUglify.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Xml" />
</ItemGroup>
<Choose>
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
Expand Down
2 changes: 1 addition & 1 deletion src/WebCompilerTest/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="AjaxMin" version="5.14.5506.26202" targetFramework="net45" userInstalled="true" />
<package id="NUglify" version="1.5.5" targetFramework="net46" />
</packages>
10 changes: 8 additions & 2 deletions src/WebCompilerVsix/WebCompilerVsix.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
<Link>Resources\LICENSE</Link>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
<Content Include="..\WebCompiler\bin\$(Configuration)\WebCompiler.pdb">
<Content Include="..\WebCompiler\bin\$(Configuration)\net46\WebCompiler.pdb">
<Link>WebCompiler.pdb</Link>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
Expand Down Expand Up @@ -231,7 +231,13 @@
<ItemGroup>
<ProjectReference Include="..\WebCompiler\WebCompiler.csproj">
<Project>{b714b5b9-27c4-443c-9517-fe5c5ef46ea2}</Project>
<Name>WebCompiler</Name>
<Name>WebCompiler</Name>
<!-- Workaround for https://github.com/dotnet/sdk/issues/433 -->
<Private>false</Private>
<IncludeOutputGroupsInVSIX>
</IncludeOutputGroupsInVSIX>
<IncludeOutputGroupsInVSIXLocalOnly>
</IncludeOutputGroupsInVSIXLocalOnly>
</ProjectReference>
</ItemGroup>
<ItemGroup />
Expand Down
13 changes: 13 additions & 0 deletions src/common.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project>
<PropertyGroup>
<Copyright>Copyright 2017</Copyright>
<Authors>Mads Kristensen</Authors>
<Description>Compiles LESS, Sass, JSX and CoffeeScript files</Description>
<PackageTags>LESS;Sass;Scss;JSX;EcmaScript6;CoffeeScript</PackageTags>
<PackageIconUrl>https://raw.githubusercontent.com/madskristensen/WebCompiler/master/src/WebCompilerVsix/Resources/icon.png</PackageIconUrl>
<PackageLicenseUrl>https://github.com/madskristensen/WebCompiler/blob/master/LICENSE</PackageLicenseUrl>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/madskristensen/WebCompiler</RepositoryUrl>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
</PropertyGroup>
</Project>