具有通用名称的 Nuget 包
Nuget packages with common Names
我在玩 NuGet,所以我创建了一个项目,编写了两个简单的函数(乘法和加法),并按照以下规范对其进行了打包:
<metadata>
<id>Math</id>
<version>1.0.0.0</version>
<title>$title$</title>
<authors>$author$</authors>
<owners>$author$</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>$description$</description>
<copyright>Copyright 2015</copyright>
<tags>Matematica, Test</tags>
</metadata>
然后在我的本地 NuGet.Server 提要上公布它,在另一个示例项目中添加我的新 nuget 包,启动它并且它 returns this:
Could not load file or assembly 'Math, Version=1.0.0.0, Culture=en-GB, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
用谷歌搜索了很多时间但一无所获(我是唯一愚蠢到调用临时包的人吗 'Math'?),所以我想我的模块名称有点像 taboo,将其更改为 Math_Test,相同的源代码,效果非常好。
是否有更多信息可以指定哪些值是 禁忌?
我在 nuget 官方文档上找不到任何东西。
class 数学在以下 dll (mscorlib.dll) 中指定,因此它甚至没有相同的 id...
#region Assembly mscorlib.dll, v4.0.0.0
// C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\mscorlib.dll
#endregion
编辑:
这是示例应用程序的代码
using Math;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int a = -1;
try
{
Common e = new Math.Common();
a = e.Multiply(3, 2);
}
catch (Exception e)
{
System.Console.Out.Write(e);
}
System.Console.Out.Write(a);
System.Console.Read();
}
}
}
似乎问题不在于名称,而在于程序集内的文化(这与 Nuget 规范中指定的语言不同。
从
更改 AssemblyCulture
[assembly: AssemblyCulture("en-GB")]
到
[assembly: AssemblyCulture("")]
解决了问题。
按照@ShyamalDesai 的建议,我在构建期间通过切换诊断输出发现了警告
CSC : warning CS1607: Assembly generation -- Referenced assembly 'Math' has different culture setting of 'en-GB'
我在玩 NuGet,所以我创建了一个项目,编写了两个简单的函数(乘法和加法),并按照以下规范对其进行了打包:
<metadata>
<id>Math</id>
<version>1.0.0.0</version>
<title>$title$</title>
<authors>$author$</authors>
<owners>$author$</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>$description$</description>
<copyright>Copyright 2015</copyright>
<tags>Matematica, Test</tags>
</metadata>
然后在我的本地 NuGet.Server 提要上公布它,在另一个示例项目中添加我的新 nuget 包,启动它并且它 returns this:
Could not load file or assembly 'Math, Version=1.0.0.0, Culture=en-GB, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
用谷歌搜索了很多时间但一无所获(我是唯一愚蠢到调用临时包的人吗 'Math'?),所以我想我的模块名称有点像 taboo,将其更改为 Math_Test,相同的源代码,效果非常好。
是否有更多信息可以指定哪些值是 禁忌? 我在 nuget 官方文档上找不到任何东西。
class 数学在以下 dll (mscorlib.dll) 中指定,因此它甚至没有相同的 id...
#region Assembly mscorlib.dll, v4.0.0.0
// C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\mscorlib.dll
#endregion
编辑: 这是示例应用程序的代码
using Math;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int a = -1;
try
{
Common e = new Math.Common();
a = e.Multiply(3, 2);
}
catch (Exception e)
{
System.Console.Out.Write(e);
}
System.Console.Out.Write(a);
System.Console.Read();
}
}
}
似乎问题不在于名称,而在于程序集内的文化(这与 Nuget 规范中指定的语言不同。 从
更改 AssemblyCulture[assembly: AssemblyCulture("en-GB")]
到
[assembly: AssemblyCulture("")]
解决了问题。
按照@ShyamalDesai 的建议,我在构建期间通过切换诊断输出发现了警告
CSC : warning CS1607: Assembly generation -- Referenced assembly 'Math' has different culture setting of 'en-GB'