0

I'm using Visual Studio 2019 to build my project, which is a .NET framework 4.6.1 WCF project. building and debugging, even publishing to folder works perfectly on my local machine from within visual studio. But trying to do the same with MSBuild on a server using Jenkins yields these error messages:

17:03:54  D:\Jenkins\workspace\workspace\R_and_D_IT\WRAP-UI\Wrap.DataAccessDapper\Mappings\ContainerMap.cs(11,33): error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. [D:\Jenkins\workspace\workspace\R_and_D_IT\WRAP-UI\AstraZeneca.RD.Wrap.DataAccessDapper\AstraZeneca.RD.Wrap.DataAccessDapper.csproj]

I'm getting one of these lines for virtually every class in that Mappings folder.

the classes themselves are fluentmap for dapper, here's one:

public class ContainerMap : EntityMap<Container>
    {
        public ContainerMap()
        {
            Map(x => x.Id).ToColumn("Container_Id");
            Map(x => x.CollectionLazyId).ToColumn("Container_Collection_Id");
            Map(x => x.Name).ToColumn("Name");
            Map(x => x.BarCode).ToColumn("Barcode");
            Map(x => x.TareWeightInMilliGrams).ToColumn("Tare_Weight");
            Map(x => x.SubstanceWeightInMilliGrams).ToColumn("Substance_Weight");
            Map(x => x.VolumeInMicroLiters).ToColumn("Volume");
            Map(x => x.IsInTrash).ToColumn("Is_In_Trash");
            Map(x => x.IsEmptied).ToColumn("Is_Emptied");
            Map(x => x.PlatePositionColumn).ToColumn("Plate_Position_Column");
            Map(x => x.PlatePositionRow).ToColumn("Plate_Position_Row");

            Map(x => x.Collection).Ignore();
        }
    }

I've tried solving this issue using this question with answers: You must add a reference to assembly 'netstandard, Version=2.0.0.0

I've tried:

  • Adding netstandard reference in web.config
  • Adding reference to netstandard in csproj file, and set copy local to true in the properties of that reference.
  • I tried deleting bin and obj folders in each project being built with this project.
  • I Installed nuget package for NetStandard.Library.NetFramework as suggested by microsoft.
  • I Tried solving it by raising framework version from 4.6.1 to 4.7.2 and updating all nuget packages involved.

Here's the commandline execution of the build in my JenkinsFile:

"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\MSBuild\\Current\\Bin\\msbuild.exe" /p:Configuration=${CONFIGURATION} /p:Platform=x64 /p:OutputPath="bin/app.publish/${CONFIGURATION}

The version of MSBuild is unknown to me, it is located in the 2019 folder of visual studio on the server, it came with a build tools package, perhaps that needs an update.

I hope anyone here can help me with this.

Edit1: I have updated the Visual Studio BuildTools on the server to latest, msbuild is the same version on both local and server. I also installed .net 4.7.2 SDK on server. yet build with msbuild works fine locally, but not on server.

inifus
  • 105
  • 2
  • 9
  • Try to add `C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\netstandard.dll` as reference in your project and set it to "copy local". – Dylan Aug 04 '21 at 07:04
  • sorry, had no effect :( I tried the same thing yesterday, today I tried it again on several projects in the solution that are linked. but no effect... – inifus Aug 04 '21 at 07:47
  • Could you use `msbuild -version` to check the version? – Dylan Aug 04 '21 at 08:09
  • 16.10.2.30804 locally where it works, 16.8.3.61104 on server where build fails. I just tried building the project that fails separately on both machines, and have isolated that it is the DataAccessDapper project that msbuild on the server can't build – inifus Aug 04 '21 at 08:18
  • I just updated the msbuild version on server so it's same version on both machines now, but no effect on the current problem. – inifus Aug 04 '21 at 08:30
  • am I missing a certain package on the server? – inifus Aug 04 '21 at 11:23

1 Answers1

0

Problem solved, apparently the Reference Include="netstandard" in the csproj file worked. but jenkins branchselector was broken and defaulted to the wrong branch, so the result never changed. this was entirely my bad and I apologise for wasting time for everyone who read this question and spent time trying to figure it out.

Hopefully this will serve someone who ends up with the same problem.

inifus
  • 105
  • 2
  • 9
  • Thanks for your sharing and that will also help other community members, you can mark this answer and this just a reminder, thanks :) – Sara Liu - MSFT Aug 06 '21 at 09:04