How to use GitVersion.Msbuild version 5.10.3 and GitVersion.Msbuild version 5.10.2 in the same solution - .net-framework-version

I have a solution that has two class libraries lets say A.csproj and B.csproj. Library A is in .NET Framework 4.8 and library B is in .netstandard2.0. A is using GitVersion.Msbuild 5.10.3 and if I try to use the same package version for library B then the build fails in the azure pipeline. But if I use GitVersion.Msbuild 5.10.2 (or any other lower version) for library B, then the build gets successfully run in the azure pipeline.
I am using below import statements in the csproj files.
For .NET Framework:
<Import Project="..\common\packages\GitVersion.MsBuild.5.10.3\build\GitVersion.MsBuild.props" Condition="Exists('..\common\packages\GitVersion.MsBuild.5.10.3\build\GitVersion.MsBuild.props')" />
For .netstandard2.0:
<Import Project="..\common\packages\GitVersion.MsBuild.5.10.2\build\GitVersion.MsBuild.props" Condition="Exists('..\common\packages\GitVersion.MsBuild.5.10.2\build\GitVersion.MsBuild.props')"/>
While restoring the packages only GitVersion.MsBuild.5.10.3 folder is created locally for .NET Framework library but GitVersion.MsBuild.5.10.2 is not getting created locally for .netstandard2.0 library. If this folder gets created then the solution will get build in both local and azure pipeline.
So in summary I want to use two different versions of GitVersion.Msbuild:- version 5.10.3 for .NET Framework and version 5.10.2 for .netstandard2.0 libaries. I want GitVersion.MsBuild.5.10.2 package folder also to be created inside ..\common\packages.
P.S.: Both the libraries are present in the same solution.
I have tried manually adding the GitVersion.MsBuild.5.10.2 folder in ..\common\packages but that is not the right way and if I remove it, while restoring the nuget packages doesn't get created for .netstandard libraries. Even I tried using the dotnet restore command from the command line that also did not create the package folder.

It should not require you to install multiple version of the same package and also having .NET Framework 4.8 and .netstandard2.0 projects should not create any problem. You have to build and restore the .netstandard libraries separately in the azure pipeline. In the yml file just add the below task:
- task: DotNetCoreCLI#2
displayName: 'Restore netstandard libraries'
inputs:
command: 'restore'
projects: '**/*.csproj'
nugetConfigPath: '$(ProjectName)\$(NugetConfigPath)'
env:
ARTIFACTORY__API_KEY: $(ARTIFACTORY__API_KEY)

Related

No Dependencies are automatically installed when adding nuget package

I'm creating a small nuget package for internal using (I created .NET standard project to use both .NET Framework or .NET Core). I created a Build Definition to build the library then push it to the Nuget Feeds of my company.
I have 2 questions:
How can I set it automatically increase the version of the my nuget package when Queue the build in tfs 2017 & Can I set some information like Author, Company...for my package?
After having the Package in the TFS Packages. I tried to add my nuget package to my project. The nuget referenced package were not automatically added to the project. I can see, it displayed "No dependencies" but in fact, I used 2 packages in my library are Newtonsoft & StackExchange.Redis. So when I run the debug, error shown "Could not find the StackExchange.Redis..."
That's strange
In my Libary project setting, I can see
There are two ways to package nuget packages. You can use "nuget pack" or "dotnet pack" (if you have some dotnet core in your solution). The difference is that dotnet pack will create a dependency section in your nuspec and you would see dependency upon installing where nuget pack will not by default unless you use an actual nuspec file. If you do create a nuspec file, you'll need to add the dependency section to you file in order to have them pop up at installation. Check here for info on the nuspec file.
For you version number it's also actually in the nuspec file in the metadata section there is a tag with the version you want. The TFS nuget pack task as a drop down you can use to send in a version number. For this task you can either use a nuspec file or the csproj directly.
You have the same options for dotnet pack using the dotnet core task
Update:
If you change your build number version pattern in the options tab for a 4 (or 3) digit pattern like $(Date:yyyy.MM.dd).$(Rev:r) e.g. 2020.03.05.xx (where xx will increment for each build in the same day and go down to 1 the next day) or 1.0.$(Rev:r) which will be 1.0.xx that will increment forever until you change the 1.0 value and then use the "Use Build Number" it will do it for you.

How to configure vcpkg for multi project solution

I am seeking advice on how to proper configure a multi project solution in relation to third party c++ libraries added with vcpkg.
How do you checkout a specific version of a library for a project?
How do you configure Visual Studio 2019 to use this version for debug and release (lib, dll, headers)?
How do I share the configuration with other developers and build servers?
Here is how I did it:
fork vcpkg repo to local repository (TFS Git in my case)
make a project-specific branch (project being internal company project, not Visual Studio project)
pile on my own port modifications
add few scripts that build a package containing only libraries aforementioned project needs (nuget on windows, 7zip for Linux), see vcpkg export command
label with package version (e.g. 1.0.0.2)
build and deploy to a share (that is properly backed up)
configure some IIS instance in company network to serve packages from aforementioned share
in Visual Studio related projects refer to nuget package
on Linux related cmake script pulls correct version of package using http GET, unpacks it and imports vcpkg cmake file
every time a change needs to be made to the package:
modify your vcpkg branch, label with next version and push
build new package version (filename should contain version)
deploy package to that share
update your cmake files and/or nuget config files
I also tried to export only 1 library (cpprestsdk) but instead vcpkg just exported everything it had installed! Can't it just export the dependent libs only?
vcpkg export cpprestsdk:x64-windows --zip

Building .a NET Core project using Jenkins always references the latest installed SDK version

I'm running a "Build a Visual Studio project or solution using MSBuild" on Jenkins for several projects to generate nuget packages.
The MSBuild used is the latest Visual Studio Build Tools
The version of the .NET Core sdk used in the project is 1.0.4
Company.Core.csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp1.0</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>
</Project>
However while executing a build the used SDK version is always the latest SDK installed on the machine (2.x).
C:\Program Files\dotnet\sdk\2.1.400\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(198,5):
error NETSDK1064: Package Microsoft.CSharp, version 4.0.1 was not found.
It might have been deleted since NuGet restore. Otherwise, NuGet restore might have only partially completed, which might have been due to maximum path length restrictions.
[C:\Workspaces\Company.Core\Company.Core.csproj]
After uninstalling the 2.1.400 SDK version i get the error:
C:\ProgramFiles\dotnet\sdk\1.1.10\Sdks\Microsoft.NET.Sdk\build\Microsoft.PackageDependencyResolution.targets(308,5):
error : Assets file 'C:\Workspaces\Company.Core\obj\project.assets.json' not found. Run a NuGet package restore to generate this file. [C:\Workspaces\Company.Core\Company.Core.csproj]
The installation used to support .net Core 1.0.4 was .NET Core 1.0.4 & 1.1.1 SDK 1.0.1 using the instructions:
Windows Server Hosting
If you are looking to host stand-alone apps on
Windows Servers, the ASP.NET Core Module for IIS can be installed
separately on servers without installing .NET Core runtime. You can
download the Windows (Server Hosting) installer and run the following
command from an Administrator command prompt:
DotNetCore.1.0.4_1.1.1-WindowsHosting.exe OPT_INSTALL_LTS_REDIST=0
OPT_INSTALL_FTS_REDIST=0
I also added RuntimeFrameworkVersion in the csproj that had no effect.
<RuntimeFrameworkVersion>1.0.4</RuntimeFrameworkVersion>^
global.json also gets ignored
{
"sdk": {
"version": "1.0.4"
}
}
It looks like you can specify the sdk version in a global.json file:
{
"sdk": {
"version": "1.0.4"
}
}
Source:
https://markheath.net/post/switching-between-netcore-sdk-versions
I think there's some confusion here. .NET Core consists of two almost separate components: the SDK and the Runtime. The SDK is used to build your code and the runtime is needed to run it.
They are versioned differently. For example, the latest SDK is 2.1.403, while the latest Runtime is 2.1.5.
A recent version of SDK can target any version of the runtime released before it. So, a 2.1.403 SDK can build applications that need 2.0 or 1.0 to run.
You can force a particular SDK to be used, by using the global.json file. You need to specify a version of the SDK that is already installed. dotnet new globaljson will generate something that you can edit the versions in. But you shouldn't need to do that. You can just use the latest SDK and ask it to build for an older runtime by setting the TargetFramework as you do.
If you do a dotnet restore, does the error NETSDK1064: Package Microsoft.CSharp, version 4.0.1 was not found. still stick around? The second error, Assets file 'C:\Workspaces\Company.Core\obj\project.assets.json' not found. Run a NuGet package restore to generate this file. backs this up. The project.assets.json is created by dotnet restore. Could you simply be missing that step?

How to deploy Nuget package '.nupkg' to IIS

we are using NuGet command line( https://www.nuget.org/downloads ) to create deploy-able NuGet package (.nupkg).
The project is in .net framework 4.6, project is build using MSBuild & created the deployment package using Nuget.exe . We need to deploy the NuGet package(.nupkg) in IIS(Internet Information Services) on windows platform.
Tried to web-search but didn't worked out. need open-source tools or mannual automated step by step process to do so.
please guide.
What do you mean by "deploy the NuGet package(.nupkg) in IIS(Internet Information Services)"?
Anyway nupkg is just an archive so you can simply get dlls out of it with and use them where you need.

Setup ASP.NET MVC 4 or 5 project with Angular 2

I am learning angular 2 with Typescript.
I am using following resource.
QuickStart with Angular 2
Now from there and other examples i found that they telling to create package.json file that lists all dependencies for project.
I think creating this package.json file and listing all dependency packages this kind of structure is followed in .NetCore Project.
In MVC 4 or 5 we have packages.config file which lists although packages that we are going to use.
I am not saying we can not use package.json file when we have package.config file.
But is there any simple way to integrate Angular 2 with typescript in MVC Webapplication project using NUGet Packages and get started?
If not available please let me know how can i setup Angular 2 with type script in ASP.Net MVC 4 or 5?
As you said, in ASP.NET MVC application you have a package.config file. This file holds the information about NuGet packages you've installed in your app. This file is related to the server-side packages.
package.json file is related to a front-end part of your app. It also holds list of packages that you've installed in your app. This time npm packages. It also holds information about your app and more. You can read more about it here.
You can't mix those files and you don't want to. Firstly, those files have different format (XML and JSON). In addition, as I said before, they hold information about different parts of your application. Lastly, and this is my personal opinion, when you create application with rich UI and use Angular2, it'd be better to split the parts of your app into 2 different projects. One of them with Web APIs and the second with the UI part only. With such structure, you will no need for packages.config in UI project and no need for package.json in Web API project.
For you last question, you can start with here. You also can take a look on this sample app.
In order to run Angular 2 in an ASP.NET MVC 4.5 (VS 2015):
1) install Node.js (at least 4.4.x), npm (at least 3.x.x) and TypeScript for Visual Studio 2015 (VS -> Tools -> Extensions and Updates -> Online). You may check your version of node and npm by running the following in the terminal: "node -v" and "npm -v".
2) copy the QuickStart files (everything what quickstart-master constains, not the folder itself) into your project (to the folder containing the .csproj file) - you can download the QuickStart files from: https://github.com/angular/quickstart
3) In the Solution Explorer click "show all files" (probably the third icon from the right, just above the search bar). Select the following files/folders and include them in the project:
app folder (answer No if asked to search for TypeScript Typings)
styles.css
index.html
package.json
tsconfig.json
typings.json
4) In Visual Studio, right click on "package.json" and select "Restore Packages" - this will install all of the packages defined in the package.json into your project.
The result of this operation is the same as running "npm install" in your project location from the terminal.
Probably there'll be some warnings in the Output window - ignore them. A new folder called "node_modules" will be generated (you need to refresh the Solution Explorer to be able to see it) - advice is not to include this folder in the project.
5) In the tsconfig.json file, next to "compilerOptions" add the following:
"compileOnSave": true
as shown below
{
"compilerOptions": {
...
},
"compileOnSave": true
}
Restart Visual Studio.
6) In Visual Studio, right click on "index.html" and click "Set as Start Page".
As a reference, here's the official documentation for running Angular
2 (quickstart) in ASP.NET 4.x (Visual Studio 2015):
https://angular.io/docs/ts/latest/cookbook/visual-studio-2015.html
Also check out the link which includes steps to run.
You need to include package.json (Angular 2 gets installed using NPM)
Run NPM install
Run the GULP tasks
Run F5 to see results.
https://github.com/mithunvp/ng2Mvc5Demo
As its already accepted still it will be alternate way to get started
If You want to install Angular4 on nuget package manager console you can use Install-Package Angular4 -Version 1.1.0 and follow these steps:
Angular 4
*********
Prerequisites
`````````````
1. Download and Install Node js
2. Install Visual studio 2015 update 3 or above
3. Download and Install TypeScript 2.6.1 for Visual Studio 2015 (https://www.typescriptlang.org/#download-links)
Follow the steps to install package.
````````````````````````````````````
1. Create an new project with empty template and include dependencies for MVC and WebApi to the project
2. Install the package using command 'Install-Package Angular4 -Version 1.1.0'
Follow the steps after package installation
```````````````````````````````````````````
1. Open Node.js Command Prompt
2. Navigate to project location(use commands such as pushd,cd etc)
3. Run the command 'npm install'

Resources