Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/332.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Jenkins上的.Net框架和体系结构不匹配_C#_.net_Jenkins - Fatal编程技术网

C# Jenkins上的.Net框架和体系结构不匹配

C# Jenkins上的.Net框架和体系结构不匹配,c#,.net,jenkins,C#,.net,Jenkins,因此,我使用Jenkins并使用c#构建一个应用程序。首先,我在本地的机器上运行Jenkins,我让它工作得很好。下一步是从运行Jenkins自己副本的外部服务器构建它。当我这样做时,我得到以下警告: C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(983,5): warning MSB3644: The reference assemblies for framework ".NETFramework

因此,我使用Jenkins并使用c#构建一个应用程序。首先,我在本地的机器上运行Jenkins,我让它工作得很好。下一步是从运行Jenkins自己副本的外部服务器构建它。当我这样做时,我得到以下警告:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(983,5): warning MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.6.1" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend. [C:\Program Files (x86)\Jenkins\workspace\Joshua_Jenkins_Freestyle\ConsoleApp2\ConsoleApp2.csproj]
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3270: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project. [C:\Program Files (x86)\Jenkins\workspace\Joshua_Jenkins_Freestyle\ConsoleApp2\ConsoleApp2.csproj]
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3270: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "System.Data", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project. [C:\Program Files (x86)\Jenkins\workspace\Joshua_Jenkins_Freestyle\ConsoleApp2\ConsoleApp2.csproj]
我相信这会导致以下错误:

UnitTest1.cs(10,21):错误CS0012:类型“System.Attribute”为 在未引用的程序集中定义。您必须添加一个 对程序集“System.Runtime,Version=4.0.0.0”的引用, 区域性=中性,PublicKeyToken=b03f5f7f11d50a3a'。[C:\程序文件 (x86)\Jenkins\workspace\Joshua\u Jenkins\u Freestyle\UnitTestProject1\UnitTestProject1.csproj] UnitTest1.cs(9,10):错误CS0616: “Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute”是 不是属性类[C:\Program Files (x86)\Jenkins\workspace\Joshua\u Jenkins\u Freestyle\UnitTestProject1\UnitTestProject1.csproj] UnitTest1.cs(18,10):错误CS0616: “Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute”是 不是属性类[C:\Program Files (x86)\Jenkins\workspace\Joshua\u Jenkins\u Freestyle\UnitTestProject1\UnitTestProject1.csproj] UnitTest1.cs(26,10):错误CS0616: 'Microsoft.VisualStudio.TestTools.UnitTesting.TestCategoryAttribute' 不是属性类[C:\Program Files (x86)\Jenkins\workspace\Joshua\u Jenkins\u Freestyle\UnitTestProject1\UnitTestProject1.csproj] UnitTest1.cs(26,35):错误CS0616: “Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute”是 不是属性类[C:\Program Files (x86)\Jenkins\workspace\Joshua\u Jenkins\u Freestyle\UnitTestProject1\UnitTestProject1.csproj] UnitTest1.cs(6,6):错误CS0616: “Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute”是 不是属性类[C:\Program Files (x86)\Jenkins\workspace\Joshua\u Jenkins\u Freestyle\UnitTestProject1\UnitTestProject1.csproj]

我一直在想办法,但没有成功

我尝试的第一件事是将项目的目标版本设置为与外部Jenkins服务器在项目引用中使用的.Net framework(4.6)相同的.Net framework。那没用


非常感谢您的帮助。

因此我在某种程度上找到了一个解决方案,尽管它在某种程度上避免了问题。我现在使用的是VSTest,它似乎工作得很好。尽管我确实认识到将用户软件下载到服务器上的不良做法。

4.6版和4.6.1版是不同的。您是否尝试过在外部服务器上安装.net 4.6.1?@PmanAce嗯,我自己没有权限这样做,因为我的工作只允许某些用户帐户访问它。我已经向他们提出了这样的要求,但我想知道在此期间我是否还有什么可以做的。特别是如果事实证明这不是问题,请看一看,也许: