<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <Title>Microsoft ASP.NET SignalR JavaScript Client</Title>
    <Description>JavaScript client for ASP.NET SignalR.</Description>

    <!-- This is just a placeholder project for some JavaScript build tools, but we need a TFM to make MSBuild happy -->
    <TargetFramework>netstandard1.0</TargetFramework>

    <NuspecFile>$(MSBuildThisFileDirectory)$(MSBuildProjectName).nuspec</NuspecFile>
    <NuspecProperties>PackageVersion=$(PackageVersion);Configuration=$(Configuration);PackageIcon=$(PackageIconFullPath);Authors=$(Authors);Owners=$(Owners);CopyrightNotice=$(Copyright);ProjectSiteUrl=$(PackageProjectUrl);ReleaseNotes=$(PackageReleaseNotes);RequireLicenseAcceptance=$(PackageRequireLicenseAcceptance);License=$(LicenseFullPath)</NuspecProperties>
    <NuspecBasePath>$(OutputPath)</NuspecBasePath>

    <!-- Suppress the DLL from the package -->
    <IncludeBuildOutput>false</IncludeBuildOutput>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="jQuery" Version="$(jQueryPackageVersion)" />
  </ItemGroup>

  <ItemGroup>
    <JSCompile Include="jquery.signalr.*.js" />
    <JSCompile Include="package.json" />
    <JSCompile Include="LICENSE.md" />
    <JSCompile Include="README.md" />
  </ItemGroup>

  <ItemGroup>
    <GeneratedJavaScript Include="$(OutputPath)jquery.signalR-$(PackageVersion).js" />
    <GeneratedJavaScript Include="$(OutputPath)jquery.signalR-$(PackageVersion).min.js" />
    <GeneratedJavaScript Include="$(OutputPath)jquery.signalR.min.js" />
    <GeneratedJavaScript Include="$(OutputPath)jquery.signalR.js" />
    <GeneratedJavaScript Include="$(OutputPath)package.json" />
    <GeneratedJavaScript Include="$(OutputPath)LICENSE.md" />
    <GeneratedJavaScript Include="$(OutputPath)README.md" />
  </ItemGroup>

  <Target Name="CompileJs" BeforeTargets="Build" Inputs="@(JSCompile)" Outputs="@(GeneratedJavaScript)">
    <Exec Command="powershell -NoProfile -ExecutionPolicy Bypass .\build.ps1 $(OutputPath) -version $(PackageVersion)"
          WorkingDirectory="$(ProjectDir)"
          Condition=" '$(OS)' == 'Windows_NT'" />
  </Target>

  <Target Name="PackJs" AfterTargets="Pack">
    <Exec Command="powershell -NoProfile -ExecutionPolicy Bypass .\pack.ps1 $(OutputPath) -packageOutputPath $(PackageOutputPath) -version $(PackageVersion)"
          WorkingDirectory="$(ProjectDir)"
          Condition=" '$(OS)' == 'Windows_NT'" />
  </Target>
</Project>