Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding .NET examples and deleting old NuGet examples #375

Merged
merged 23 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
35b9e26
adding nuget single example
eranturgeman Sep 20, 2023
527540e
Merge branch 'master' of https://github.com/jfrog/project-examples in…
eranturgeman Sep 26, 2023
99a5a1e
changed dir name
eranturgeman Sep 26, 2023
155468c
adding dotnet examples
eranturgeman Sep 26, 2023
5aae263
changing nuget examples
eranturgeman Sep 26, 2023
fd6dc31
deleting all old NuGet projects in nuget-examples
eranturgeman Sep 27, 2023
06d4753
adding readme
eranturgeman Sep 27, 2023
1825a83
Update dotnet-examples/README.md
eranturgeman Oct 2, 2023
2a5c4ac
added command to console commands
eranturgeman Oct 2, 2023
dbd6aa1
Merge branch 'add-nuget-example' of https://github.com/jfrog/project-…
eranturgeman Oct 2, 2023
ac5f8cd
Update dotnet-examples/README.md
eranturgeman Oct 2, 2023
8280530
Update dotnet-examples/README.md
eranturgeman Oct 2, 2023
178666f
Update dotnet-examples/README.md
eranturgeman Oct 2, 2023
e54a820
Update dotnet-examples/README.md
eranturgeman Oct 2, 2023
e3bc138
Update dotnet-examples/README.md
eranturgeman Oct 2, 2023
3df8a35
Update dotnet-examples/README.md
eranturgeman Oct 2, 2023
d6b74b8
Update dotnet-examples/README.md
eranturgeman Oct 2, 2023
ab9dc09
Update dotnet-examples/multi-example/TestApp1/TestApp1.csproj
eranturgeman Oct 2, 2023
5454a46
Merge branch 'add-nuget-example' of https://github.com/jfrog/project-…
eranturgeman Oct 2, 2023
d0621ee
fixed PR issues
eranturgeman Oct 2, 2023
bb96bdc
Update dotnet-examples/README.md
eranturgeman Oct 2, 2023
b72a2d4
fixed PR issues
eranturgeman Oct 2, 2023
afdd25e
Merge branch 'add-nuget-example' of https://github.com/jfrog/project-…
eranturgeman Oct 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions dotnet-examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# .NET examples

## Overview
Artifactory provides full support for managing .NET/NuGet packages and ensures optimal and reliable access to nuget.org. It also allows aggregating multiple NuGet registries under a virtual repository Artifactory, which provides access to all your .NET/NuGet packages through a single URL for both upload and download.
To work with NuGet repositories you need to use [JFrog CLI](https://www.jfrog.com/confluence/display/CLI/CLI+for+JFrog+Artifactory) and have your .Net/NuGet project configured to an Artifactory server.

You may store exhaustive build information in Artifactory by running your .NET/NuGet builds with JFrog CLI. JFrog CLI collects build-info from your build agents and then publishes it to Artifactory. Once published, the build info can be viewed in the Build Browser under Builds. For more details on .NET/NuGet build integration using JFrog CLI, please refer to [Building .NET/NuGet Packages](https://jfrog.com/help/r/jfrog-cli/building-nuget-packages) in the JFrog CLI User Guide

## These Examples
These examples demonstrate how to build a .NET/NuGet project using JFrog CLI. The build does the following:

1. Downloads its NuGet dependencies from Artifactory.
2. Packs and uploads the built package to Artifactory.
3. Records and publishes build-info to Artifactory.

## Prerequisites
* Install .NET Core 3.1 SDK or a later version - for full support you must have .NET CLI on your machine
* Make sure the **dotnet** command is in your PATH (you can check by executing 'dotnet --version' and get a version number as a response).
* Install [JFrog CLI](https://jfrog.com/getcli/)
* Make sure your JFrog CLI version is 2.25.3 or above

# Creating Repositories
Create the following repositories on your Artifactory instance:

1. A remote NuGet repository. Make sure the repository has *https://www.nuget.org/* configured as its URL (this is the default when creating the repository).
2. A local NuGet repository.
3. A virtual NuGet repository:
- Include the remote and local repositories as part of the new virtual repository.
- Set the new local repository as the **Default Deployment Repository** of the new virtual repository.

## Running the Examples
'cd' to one of the project's root directory and run the build using one of the following commands:

```console
Configure Artifactory:
> jf c add --url=<JFROG_PLATFORM_URL> [credentials flags]

Configure the project's repositories:
> jf dotnet-config --repo-resolve=<NUGET_RESOLUTION_REPOSITORY>

Restores the dependencies and tools of the project from Artifactory
> jf dotnet restore --build-name=my-build --build-number=1

Execute 'audit' scan command.
> jf audit

Build the project with dotnet and resolve the project dependencies from Artifactory.
> dotnet pack

Upload the packages to a NuGet repository in Artifactory:
> jf rt u "*.nupkg" <NUGET_DEPLOYMENT_REPOSITORY>/ --build-name=my-build --build-number=1

eranturgeman marked this conversation as resolved.
Show resolved Hide resolved
Collect environment variables and add them to the build info.
> jf rt bce my-build 1

Publish the build info to Artifactory.
> jf rt bp my-build 1
```
15 changes: 15 additions & 0 deletions dotnet-examples/multi-example/ClassLibrary1/ClassLibrary1.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Platforms>AnyCPU;x64</Platforms>
<Company>Some Compnay</Company>
<Product>Some product</Product>
<Copyright>Some copyright</Copyright>
<Version>1.0.0</Version>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="snappier" Version="1.1.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects Condition="'$(MSBuildVersion)' == '' Or '$(MSBuildVersion)' &lt; '16.0'">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<HasSharedItems>true</HasSharedItems>
<SharedGUID>64bb14a4-9a54-4444-8b83-e8405a1b83a2</SharedGUID>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<Import_RootNamespace>SharedProject1</Import_RootNamespace>
</PropertyGroup>
<ItemGroup>
</ItemGroup>
</Project>
13 changes: 13 additions & 0 deletions dotnet-examples/multi-example/SharedProject1/SharedProject1.shproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>64bb14a4-9a54-4444-8b83-e8405a1b83a2</ProjectGuid>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
<PropertyGroup />
<Import Project="SharedProject1.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
</Project>
32 changes: 32 additions & 0 deletions dotnet-examples/multi-example/TestApp1/TestApp1.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Company>Some Company</Company>
<Version>1.0.0</Version>
<Product>Some product</Product>
<Copyright>Foobar</Copyright>
<Authors>Frederik</Authors>
<Platforms>AnyCPU;x64</Platforms>
eranturgeman marked this conversation as resolved.
Show resolved Hide resolved
<IsPackable>false</IsPackable>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<OutputPath>bin\x64\Release\</OutputPath>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\ClassLibrary1\ClassLibrary1.csproj" />
</ItemGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" Version="2.1.1" />
<PackageReference Include="Google.Cloud.Kms.V1" Version="2.0.0" />
</ItemGroup>

</Project>
31 changes: 31 additions & 0 deletions dotnet-examples/multi-example/TestSolution.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.32106.194
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApp1", "TestApp1\TestApp1.csproj", "{757C1D5A-BAA9-453F-B612-A0571390976B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassLibrary1", "ClassLibrary1\ClassLibrary1.csproj", "{D9C89660-69F8-46E2-B9C4-78E9B505E8B1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{757C1D5A-BAA9-453F-B612-A0571390976B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{757C1D5A-BAA9-453F-B612-A0571390976B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{757C1D5A-BAA9-453F-B612-A0571390976B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{757C1D5A-BAA9-453F-B612-A0571390976B}.Release|Any CPU.Build.0 = Release|Any CPU
{D9C89660-69F8-46E2-B9C4-78E9B505E8B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D9C89660-69F8-46E2-B9C4-78E9B505E8B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D9C89660-69F8-46E2-B9C4-78E9B505E8B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D9C89660-69F8-46E2-B9C4-78E9B505E8B1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D8547989-C4F7-4FCC-95BB-F7478F7D2484}
EndGlobalSection
EndGlobal
2 changes: 2 additions & 0 deletions dotnet-examples/single-example/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");
15 changes: 15 additions & 0 deletions dotnet-examples/single-example/single-example.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<RootNamespace>single_example</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="snappier" Version="1.1.0" />
</ItemGroup>

</Project>
20 changes: 0 additions & 20 deletions nuget-example/MyLogger/MyLogger.sln

This file was deleted.

16 changes: 0 additions & 16 deletions nuget-example/MyLogger/MyLogger/MyLogger.cs

This file was deleted.

53 changes: 0 additions & 53 deletions nuget-example/MyLogger/MyLogger/MyLogger.csproj

This file was deleted.

13 changes: 0 additions & 13 deletions nuget-example/MyLogger/MyLogger/MyLogger.nuspec

This file was deleted.

36 changes: 0 additions & 36 deletions nuget-example/MyLogger/MyLogger/Properties/AssemblyInfo.cs

This file was deleted.

3 changes: 0 additions & 3 deletions nuget-example/TeamCity-Config/NuGet/plugin-settings.xml

This file was deleted.

Loading
Loading