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.