I read the following both articticles about the using of portable class library(PCL) in application design:
http://www.dotnetcurry.com/showarticle.aspx?ID=843
and
http://blogs.msdn.com/b/dsplaisted/archive/2012/08/27/how-to-make-portable-class-libraries-work-for-you.aspx
I created an PCL and a unit test project to test the PCL. I build everything with my visual studio 2012 and it works great, i was also able to start my application using this PCL.
I use a TFS for source controll and nightly tests.
If i try to build the the unit test project or my apllication via TFS i retrieve two errors:
CA0055 : * Could not load file: 'C:...\MyPCL.dll'.
CA0052 : No targets were selected.
The PCL use .Net Framework 4.5 and .Net for Windows Store apps as targets and all projects which are no PCL are configured to use .Net Framework 4.5. I does not use any other reference as the default ".Net Protable Subset" reference.
If i check the build server there is a compiled and working version of my PCL.
If i disable the code analysis while building there are no errors and all unit test works fine.
But it is no solution for me to disbale the code analysis. So has anybody an idea why it crashed and how to get it working with code analyse?
I ran into the same problem after renaming the project. Check the AssemblyInfo.cs file, make sure the assemblyTitle is correct. Better to have it same as the project name, and is not conflicting with any other projects
Is your local build working fine when code analysis is enabled in Visual Studio?
If yes then one of the possible reason for this issue can be build output path in TFS Build. In local builds, output files are generated in bin directory of respective projects where as in TFS Build all the project output files are copied in binaries directory.
Related
I create a new C# project WPF Application - A project for a .NET Core WPF Application.
Framework: .NET Core 3.1.
Project loaded. (you have an empty form)
Right click on your project and check that you have "Output type" Windows application. (It means when you click on build it creates an EXE file in BIN folder of your project)
Then add a new project to the solution : Setup Wizard by extension Microsoft Visual Studio Installer Projects. Then follow steps as is here -> https://stackoverflow.com/a/6090929/15917420
In the end it packages DLL into installator file instead EXE.
So if you take setup.exe and install it, it installs DLL.
Do you have same problem or am I missing something?
If I create WPF with .NET Framework I dont have this problem.
Thank you
EDIT: recorded video: https://drive.google.com/file/d/11ElC0F62klxQOI-beOn6LhcZbyOb7QDT/view?usp=sharing
I had the same issue. Microsoft has published this:
https://learn.microsoft.com/en-us/visualstudio/deployment/installer-projects-net-core?view=vs-2019
Basically is says that for .NET Core projects, you have to use the "published items" instead of "primary output" when building the setup project. It also has a couple of other hints too.
When targetting .NET Core, the "main" project (the one that is the application) gets two files, a dll and an exe file. The exe file is only a stub loader that locates the dotnet runtime and transfers control to the corresponding dll. Simply put, the exe of a .NET core project is executing the dotnet <dll-with-the-same-name>-command.
With this in mind, you need to make sure that your installer installs both the dll and the exe (and any other similarly named files, such as <Application>.deps.json).
I am working on a project that requires me to build a .dll file in .NET framework 4.x
I know this would be super easy if I were to use Visial Studio. But I have set my mind on using VS Code as my IDE.
In theory Visual Studio "only" automates the creation of all sorts of metadata and references. So I figured it should be possible to do these things manually. Correct?
Can anybody direct me to where I can find how to do that?
I am working on Windows 10.
Because Code isn't adept at managing a project file (.csproj) - nor should anyone have to - you can actually use the dotnet.exe CLI to create the project and target .NET Framework instead. The only requirement is that .NET Core SDK needs to be installed, even if you use MSBuild because the new SDK-style project requires different targets.
Run: dotnet new classlib -o MyLibrary
Run: code MyLibrary
Open MyLibrary.csproj in Code
Change the line <TargetFramework>v4.5</TargetFramework>
Now you can run dotnet build or msbuild build, and even set up build and test tasks in Code. By default, Ctrl+Alt+B will run a build task, or prompt to create one from a template if none exist yet.
Now you can simply add files without modifying the .csproj file. I participate in many OSS projects that use technique and can easily switch between VS, Code, or even non-IDEs like vim.
It would require from you to type a lot of code and files that are otherwise automatically scaffold (generated) when you create a new project in Visual Studio. Even though VS Code is supportive for .NET framework coding (with the C# plugin), I would advice you to use Visual Studio (the community version would suffice). It has much better support for any .NET framework development.
I have a .Net/C# solution which contains two projects:
Web Project (ASP.Net Web API)
Unit-Test project (C#, etc)
The Unit Test project references the Web Project and using a Test Framework performs some unit tests against it.
In Visual Studio 2017, all of this builds perfectly run and the web api runs perfectly and so do my unit tests.
When I come to build is using MSBuild via the command line (either locally or on own build server), the Unit Test project reports...
error CS0103: The name 'WebApi' does not exist in the current context [c:\Code\UnitTests.csproj]
...it can't find the WebApi project at all!
Both projects are configured as .Net V4.5.2 and 'Any CPU'.
I've tried various:
Versions of MsBuild
Versions of the C# Language (in case C# 6 was causing issues as msbuild doesn't always support C# V5)
I'm building them using
c:\Program Files (x86)\MSBuild\14.0\Bin\msbuild.exe" C:\Code\MyProject.sln /t:Rebuild /p:Configuration=Release
Additionally, the Unit Test project can reference other .Net Class Libaries and other ASP.NET Web API projects without problem, so it must be something to do with the ASP.NET Web API project rather than the Unit Test project itself.
I've noticed that when msbuild comes to compile the Unit Test project it shows the command line for the csc.exe compile part and it will include all references to other project, but never includes the Web API project, so msbuild must either:
Think the Web Api reference is not required and ignores it, or
Fails to detect it in the csproj file (but VS detects it perfectly fine)
Update: The Web API project was added to the solution 2-3 years ago (likely VS2013/5), but the Unit Test project was added this week using VS 2017, but I also tried VS2015 and same error.
Any other ideas?
When I build my .NET Core 2.0 console app, I move it over to the server and I then try and run it. I am getting the error "An assembly specified in the application dependencies manifest..."
I add the dlls to the local folder that it is searching for, but it ends up still needing system dlls like Data.SqlClient.
How do I build the project where it includes all the dependencies in the output files? I've published the project with Visual Studio 2017, however, it still says things are missing when I copy all those files over. I've tried building and publishing with VSCode and have the same problem.
I faced a similar problem. When I deployed my application in host environment and executed with dotnet command like "dotnet myapp.dll" it worked fine using the host environment's .NET Core runtime.
But when I packaged the same application as a Standalone application with an .exe file included to start the application, I faced this error for Newtonsoft.json Nuget Package when .exe file is executed.
My observation is as below, and I was able to solve the problem accordingly.
Framework-dependent deployment:
If the application uses third-party libraries and intention is to use the .NET Core runtime in the host environment, then the checkbox in the "Manage Packages for Solution" has to be checked in the Nuget Package Manager (as shown in the screenshot).
Self-contained deployment:
If the published application is supposed to be a stand alone application in the host environment (even with an .exe file), then the application's .csproj file should include the RuntimeIdentifiers (.NET Core RIDs) specified. Also the third party libraries have to be included in PackageReference. For example,
Reference: https://learn.microsoft.com/en-us/dotnet/core/deploying/deploy-with-vs
You need to publish the application to have all the dependencies included
I'm trying to build my solution using TeamCity / MSBuild.
It's a WebAPI project which shares some entities in a PCL with a mobile client.
I see there are a few caveats around getting the PCL reference libraries installed on a buildserver, which I think I've sorted
(Building Portable Class Library Project in build server fails)
However, I'm getting an error during the build of the portable class library as follows:
[11:20:49][Doctrina.Pcl.Entities\Doctrina.Pcl.Entities.csproj] _GetSdkToolPaths
[11:20:49][_GetSdkToolPaths] GetSdkPropertyValue
*[11:20:49][GetSdkPropertyValue] C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\AppxPackage\Microsoft.AppXPackage.Targets(975, 5): error APPX3212: SDK root folder for 'Portable 7.0' cannot be located. See http://go.microsoft.com/fwlink/?prd=12560&pver=1.0&plcid=0x409&ar=MSDN&sar=PlatformMultiTargeting&o1=Portable&o2=7.0 for more information.*
The "help" link doesn't go anywhere useful and it seems to be very google-resistant in terms of finding any resolution.
I don't have Visual Studio 2015 installed on the build-server at all, but I have installed PortableClassLibrary tools, copied the reference directory from my local PC over, etc, as per the other related SO question.
Help please?
I encountered this error when attempting to build portable projects targeting .NET Standard.
I managed to resolve it without installing Visual Studio on my build server, by copying from a machine that does have Visual Studio installed:
C:\Program Files (x86)\Microsoft SDKs\Portable\v14.0
C:\Program Files (x86)\MSBuild\Microsoft\Portable
C:\Program Files (x86)\ReferenceAssemblies\Microsoft\Framework.NETPortable
I later attempted to build a WebApi project targeting .NET Core (this was an xproj file) and as soon as I added the XProj file to my solution, I had to also copy:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet.Web
That got me a bit further but it also caused other projects to stop building properly (that were working fine without the XProj file in the solution). One thing I noticed, the NuGet tooling for .NET Core does not support authenticated NuGet feeds, so I had to enable anonymous access on my feed. But now my .NET Standard project now fails with error MSB4057: The target "_GenerateDependencyFragmentJson" does not exist in the project.
I've yet to get around to diagnosing this, but I hope the above information helps someone. If you're not using xproj files and just trying to use .NET Standard projects, the above should be all you need to build without installing Visual Studio.
Just a side note, I tried really hard to avoid having to copy these files by first trying to install Microsoft Build Tools 2015 Update 3, hoping it would put the required files in place, but it did not sadly. I'm pinning my hopes on the next version of MSBuild that is being used in VS15, and hoping that it's build tools package will have everything required to build this stuff when it comes out, as it doesn't seem like they are updating the 2015 Build Tools with this support.