花了我一些時間,但我想出瞭如何使用NuGet。 首先,我在PC上添加了一個位置,作爲包的來源,解釋如下here。
在VS2013 CE中,您可以通過打開NuGet程序包管理器設置(工具> NuGet程序包管理器>程序包管理器設置)並在程序包源代碼下在計算機上添加位置。
要創建NuGet,我組合了幾個HowTo,因爲單獨一個人沒有工作。 主要的是this。
我爲我所需要的平臺DLL和創建以下文件夾結構
,因爲它可能是一個有點難以看到ProjectName.props和ProjectName.targets位於netcore451文件夾中。 lib中的.dll,.pri和.winmd是x86版本。根據HowTo它是多餘的,你可以忽略這些文件,但沒有它們可能無法在設計模式下正常工作。
在包含建立和lib我創建了一個文件ProjectName.nuspec
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd">
<metadata minClientVersion="2.5">
<id>ProjectName</id>
<version>1.0.0</version>
<authors>Stefan Fabian</authors>
<owners>Stefan Fabian</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Description</description>
<releaseNotes>First release.</releaseNotes>
<copyright>Copyright 2015</copyright>
<references>
<group targetFramework=".NETCore4.5.1">
<reference file="ProjectName.winmd" />
</group>
</references>
</metadata>
</package>
ProjectName.props
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>
ProjectName.targets
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="PlatformCheck" BeforeTargets="InjectReference"
Condition=" (('$(Platform)' != 'x86') AND ('$(Platform)' != 'AMD64') AND ('$(Platform)' != 'Win32') AND ('$(Platform)' != 'ARM') AND ('$(Platform)' != 'x64'))">
<Error Text="$(MSBuildThisFileName) does not work correctly on '$(Platform)'
platform. You need to specify platform (x86/x64 or ARM)." />
</Target>
<Target Name="InjectReference" BeforeTargets="ResolveAssemblyReferences">
<ItemGroup Condition="'$(Platform)' == 'x86' or '$(Platform)' == 'Win32'">
<Reference Include="ProjectName">
<HintPath>$(MSBuildThisFileDirectory)x86\ProjectName.winmd</HintPath>
</Reference>
</ItemGroup>
<ItemGroup Condition="'$(Platform)' == 'x64' or '$(Platform)' == 'AMD64'">
<Reference Include="ProjectName">
<HintPath>$(MSBuildThisFileDirectory)x64\ProjectName.winmd</HintPath>
</Reference>
</ItemGroup>
<ItemGroup Condition="'$(Platform)' == 'ARM'">
<Reference Include="ProjectName">
<HintPath>$(MSBuildThisFileDirectory)ARM\ProjectName.winmd</HintPath>
</Reference>
</ItemGroup>
</Target>
</Project>
我不是文件夾確定是否有必要檢查x86和Win32,但它適用於我。
免責聲明
這是第一次我創建了一個NuGet包和上面的代碼可能會吸。
這是一個Windows錯誤,0xC1 == 193 == ERROR_BAD_EXE_FORMAT。這應該不會令人驚訝,你確實需要構建該DLL的x64版本。或者只是不打擾,提交一個32位的應用程序是好的。 –
是的,我知道了,但我不知道有什麼辦法可以告訴VS使用x64配置的x64版本和x86配置的x86版本。 我想也只是把它改成32bit,但是ARM呢? –
看起來另一種可能的方式可能是創建一個包含所有3個平臺版本的私人nuget。 但是這似乎有點過於複雜,如果有人知道更好的方法,我會非常感激。 –