Skip to content

Commit 1718058

Browse files
committed
Support packages.config (dotnet#165)
Copy our native assemblies using MSBuild when a consumer is using NuGet packages.config, since NuGet doesn't do this automatically. Also, add an error when a project is not targeting x64. ML.NET only supports x64. Fix dotnet#93
1 parent 462f9d4 commit 1718058

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

pkg/Microsoft.ML/Microsoft.ML.nupkgproj

+3
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,7 @@
1414
<PackageReference Include="System.ValueTuple" Version="$(SystemValueTupleVersion)" />
1515
</ItemGroup>
1616

17+
<ItemGroup>
18+
<Content Include="build\**\*" Pack="true" PackagePath="build" />
19+
</ItemGroup>
1720
</Project>
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2+
3+
<!--
4+
NuGet packages.config doesn't support native assemblies automatically,
5+
so copy the native assemblies to the output directory.
6+
-->
7+
<ItemGroup Condition="Exists('packages.config') OR
8+
Exists('$(MSBuildProjectName).packages.config') OR
9+
Exists('packages.$(MSBuildProjectName).config')">
10+
<Content Include="$(MSBuildThisFileDirectory)\..\runtimes\win-x64\native\*.dll"
11+
Condition="'$(PlatformTarget)' == 'x64'">
12+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
13+
<Visible>false</Visible>
14+
</Content>
15+
</ItemGroup>
16+
17+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2+
3+
<PropertyGroup>
4+
<EnableMLUnsupportedPlatformTargetCheck Condition="'$(EnableMLUnsupportedPlatformTargetCheck)' == ''">true</EnableMLUnsupportedPlatformTargetCheck>
5+
</PropertyGroup>
6+
7+
<Target Name="_CheckForUnsupportedPlatformTarget"
8+
Condition="'$(EnableMLUnsupportedPlatformTargetCheck)' == 'true'"
9+
AfterTargets="_CheckForInvalidConfigurationAndPlatform">
10+
11+
<!--
12+
Special case .NET Core portable applications. When building a portable .NET Core app,
13+
the PlatformTarget is empty, and you don't know until runtime (i.e. which dotnet.exe)
14+
what processor architecture will be used.
15+
-->
16+
<Error Condition="'$(PlatformTarget)' != 'x64' AND
17+
('$(OutputType)' == 'Exe' OR '$(OutputType)'=='WinExe') AND
18+
!('$(TargetFrameworkIdentifier)' == '.NETCoreApp' AND '$(PlatformTarget)' == '')"
19+
Text="Microsoft.ML currently supports 'x64' processor architectures. Please ensure your application is targeting 'x64'." />
20+
</Target>
21+
22+
</Project>

0 commit comments

Comments
 (0)