花了我一些时间,但我想出了如何使用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。 但是这似乎有点过于复杂,如果有人知道更好的方法,我会非常感激。 –