How to build OPC Foundation .NET library with Visual Studio - c#

I am trying to build the OPC foundation provided SDK by visual studio. I face lots of builds error.
I tried VS2013, VS2017 community version, and VS2019 professional version.
Does anybody have experience building this SDK?
The source code can be downloaded from Github.
https://github.com/OPCFoundation/UA-.NETStandard
Following images show the dot net version and the errors

Which solution are you trying to build?
As astrowalker indicated can you share the error messages?
This worked for me:
cloned the repository
opened solution "UA Core Library" within VS2019
restore nuget packages
rebuild solution
run all test of project "Opc.Ua.Core.Tests"

Related

Visual Studio 2019 shows an empty solution after creating a .NET Core project

When I create a new .NET Core project in Visual Studio 2019, it shows only the solution file. Other files are not showing and also I am not able to debug or the project.
I've also run into this problem and after two days of searching forums and reading .NET documentations, I finally managed to find the solution.
The problem is that Visual Studio cannot find the proper SDK version. There might be a few reasons for this, but first of all, check if you have any SDK installed:
Open the Command Prompt:
Start Menu > Visual Studio 2019 > Developer Command Prompt for Visual Studio 2019
Run the command: dotnet --info
Case 1:
The .NET SDKs installed: section says that you have no SDKs installed.
-OR-
A .NET SDK is installed but not for the right architecture (this was my case), meaning that you had installed x86 version instead of x64.
Solution:
Uninstall all versions of .NET Core SDKs and Runtimes, then download and install the latest x64 SDK and Runtime version from Microsoft's webpage.
Case 2:
A .NET SDK is installed but the referenced SDK version in the current project's .csproj file does not match the installed version nor the one specified in the global.json (if exists).
Solution: Edit the .csproj file, so that the SDK versions match.
If you have or need a global.json file, make sure you set its content properly. You can read more about it here.
Finally
Don't forget to open Visual Studio, create a new e.g. Console Application and see if the Solution's files appear in the Solution Explorer window (they should). Note that existing projects may still not be working properly because their .csproj file might have wrong SDK reference - if so, you have to fix them manually.

Downgrading .NET Framework causing packages issues

I am working on a project on TFS. This project was created on someone else's PC on VS 2017 and the newest .NET framework and published to Azure.
I got the project on my PC, I have VS 2015 and I had to change the .NET framework of the project to 4.6. Everything was fine, I could make changes to the project and commit.
But when I tried to publish to Azure from my PC, I got a very unclear error:
Publish Failed
Connecting to ...
Looking for solutions online, I had to downgrade the version of the package Microsoft.Net.Compilers from 2.6.1 to 2.4.0 . And that worked !
I turned off my PC. Next day when I opened the project and ran it, I got this error locally :
Could not load file or assembly 'Microsoft.ApplicationInsights, Version=2.6.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
I tried to uninstall Microsoft.ApplicationInsights and reinstall it with version 2.6.1 , but it says i need a newer version of nuget.
I am not sure how to proceed from here. I already installed all the updates in my Tools -> Extensions -> Updates but nothing changed.
Why are all these things happening to my project and how can i fix it?
PS: upgrading my VS to 2017 is currently not an option due to many exterior reasons.
Thank you.
I've gotten that error locally as well and was actually able to resolve by manually adding the file to my project folder, may be worth a shot.
Downgrading .NET Framework causing packages issues
Just like Hans said nuget packages change quite rapidly, which often require the latest version NuGet. Some new features in the package only supported by the newer NuGet (like PackageReference) or some issues fixed on the newer version. For example, install package Microsoft.EntityFrameworkCore.SqlServer 2.1.1 on Visual Studio 2015, which requires NuGet client version '3.6.0' or above.
So, the workaround for this issue is create a new project with Visual Studio 2015, copy the code from previous projects, then add those nuget package one by one to find out the reason why it needs the newer version nuget.
However, I want to talk more over about this question is that the best way to resolve this issue is to install Visual Studio 2017 alongside Visual Studio 2015. As we known, using a lower version of the Visual Studio and .net framework to open a higher version of the Visual Studio and .net framework is not recommended, it will always bring a lot of incompatibility errors and some other weird issues. Since upgrade your Visual Studio to 2017 is currently not an option due to many exterior reasons, so I suggest that you can install Visual Studio 2017 alongside Visual Studio 2015. Besides, developing the same project with different versions of Visual Studio and submitting it to the TFS server may bring many unpredictable risks.
Hope this helps.

MSBuild update, where dos this come from?

Here is the context :
2 persons are working on a WPF application (me and a colleague)
we both use the VS 2017 (i have the version 15.6.6 he has the version 15.6.4)
we are both using the most recent and fully updated .NET Framework
we are using MSI installation system to deploy our WPF application + Win services
we are using WIX to package all this
But something strange happened: when I generate the installer, the netstandard.dll version deployed is the 4.6.25908.2, and when he generates the installer, the netstandard.dll is the 4.6.26011.1
After some research, we discover that this dll is coming from MSBUILD, and by checking in the "Developer Command Prompt for VS 2017", using the "msbuild" command :
- my version is 15.5.180.xxxx
- his version is 15.6.6.xxxx
My question is pretty simple, what is responsible for updating msbuild package?
Obviously, not VS or .Net Framework
I have found some nugget package to add to my projects but I don't want this, I want this dll to be updated properly in "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib" directory
How can I manage to achieve this?
Ok I found what was going on and there was no way to find out with what I posted.
This is the story :
I installed VS 2017 Pro with a license
I tried VS 2017 Enterprise for sometimes with a trial license
VS 2017 setup made 2 distinct installations
After the trial license expired, I was still using then Enterprise installation downgraded to a Pro version
The Enterprise version was up to date but not the original Pro version
Conlusion: by updating the VS 2017 Pro version specifically, it solved my problem
#Hans Passant: the MSBUILD was indeed updated with VS 2017, but for some reason, I don't really understand, I have to update both Pro and Enterprise version to 15.6.6.xxxx in order to update MSBUILD properly

Visual Studio 2017 Enterprise Add Unit Test project throws Package Installation Error

I have a solution with projects pointing to .Net Framework 4.5 which I have opened in Visual Studio 2017 and tried to Unit Test Project pointing to .Net Framework 4.5. I am getting the following error
Package Installation error .
Could not add all required packages to the project. The following packages failed to install from 'C:\Program Files(x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\Extensions\502SXCIF.E5I\Packages':
MSTest.TestFramework.1.1.11: Failed to add reference to 'Microsoft.VisualStudio.TestPlatform.TestFramework'
I have tried changing the Platform to x86 as suggested on some online resources.
I am using a Windows 7 Enterprise 64 bit. Has anyone been able to resolve this.
MsUnit test related template got missed in your local system.if you have another version please try to copy respective folder it will resolve the issue.

VS 2015 solution build fails with error some pkg not compatible with .net framework 4.5

Recently VS 2015 is not building my solution and I keep getting pkg errors like
I have following .net framework installed
I dont know whats worng , I was able to build it successfully better but after recent windows updates it's not building anymore.
I deleted the %USERPROFILE.nuget\packages directory
Then did nuget package restore and it started building successfully.

Categories

Resources