Update samples directory

This commit is contained in:
Rich Lander 2020-08-20 17:34:06 -07:00
parent cf54951f3e
commit 79ae836952
13 changed files with 14 additions and 255 deletions

View file

@ -1,19 +1,19 @@
# .NET Core Samples
# .NET Samples
This directory contains samples that you can use to test out [.NET Core](http://dotnet.github.io). They are small and simple, and are used to get your feet wet with .NET Core as fast as possible.
This directory contains samples and documents that you can use to test out .NET.
## How to run the samples?
* [dotnetsay tools](dotnetsay/README.md)
* [Raspberry Pi instructions](RaspberryPiInstructions.md)
* [Using Xml Serializer Generator on .NET Core](xmlserializergenerator-instructions.md)
* [nuget.config for daily .NET builds](nuget.config)
* [linker instructions](linker-instructions.md)
* [.NET Core on Yocto instructions](YoctoInstructions.md)
* [Using dotnet-svcutil.xmlserializer on .NET Core](dotnet-svcutil.xmlserializer-instructions.md)
In order to run these samples, you first need to [install .NET Core](http://dotnet.github.io/getting-started/). After that, you can clone this repo, go into each of the samples folders and either:
## Other resources
* Run from source using the following commands:
* `dotnet run`
* Compile and run using the following commands
* `dotnet build`
* `dotnet bin/Debug/[framework]/[binary name]`
* [Install .NET](https://dotnet.microsoft.com/download/)
* [.NET documentation](https://docs.microsoft.com/dotnet)
* [.NET samples](https://github.com/dotnet/samples)
## Samples list
* **dotnetbot** - Let dotnetbot say Hi!
* **helloworld** - because no sample is complete without Hello World!
* **qotd** - a simple "quote of the day" console application (**note**: this sample is not yet capable of being compiled to a native binary).

View file

@ -1,4 +0,0 @@
FROM microsoft/dotnet
COPY bin/Debug/netcoreapp1.0 app
WORKDIR app
ENTRYPOINT ["dotnet", "dotnetbot.dll"]

View file

@ -1,62 +0,0 @@
using System;
public static class Program
{
public static void Main(string[] args)
{
string message = "dotnet-bot: Welcome to using .NET Core!";
if (args.Length > 0)
{
message = string.Join(" ", args);
}
Console.WriteLine(GetBot(message));
}
public static string GetBot(string message)
{
string bot = $"\n {message}";
bot += @"
__________________
\
\
....
....'
....
..........
.............'..'..
................'..'.....
.......'..........'..'..'....
........'..........'..'..'.....
.'....'..'..........'..'.......'.
.'..................'... ......
. ......'......... .....
. ......
.. . .. ......
.... . .......
...... ....... ............
................ ......................
........................'................
......................'..'...... .......
.........................'..'..... .......
........ ..'.............'..'.... ..........
..'..'... ...............'....... ..........
...'...... ...... .......... ...... .......
........... ....... ........ ......
....... '...'.'. '.'.'.' ....
....... .....'.. ..'.....
.. .......... ..'........
............ ..............
............. '..............
...........'.. .'.'............
............... .'.'.............
.............'.. ..'..'...........
............... .'..............
......... ..............
.....
";
return bot;
}
}

View file

@ -1,37 +0,0 @@
# dotnet-bot Sample
The dotnet-bot sample demonstrates "hello world" type usage of .NET Core. It displays [dotnet-bot](https://github.com/dotnet-bot), the open source mascot for .NET Core projects. This sample is very similar to the Docker [whalesay](https://docs.docker.com/engine/getstarted/step_three/) sample.
## Topics
You will exercise the following topics in this sample.
- Building and running a .NET Core application.
- Creating a Docker image for a .NET Core application.
- Running a .NET Core application in container.
## Script
Follow these steps to try out this sample. The instructions are intended to be Operating System agnostic, unless called out.
**Preparing your Environment**
1. Install the [.NET Core SDK](https://dot.net/core) (2.1 or higher) for your operating system.
2. Git clone this repository or otherwise copy this sample to your machine: `git clone https://github.com/dotnet/core/`
3. Navigate to the sample on your machine at the command prompt or terminal.
**Run the application**
4. Run application: `dotnet run`
5. Alternatively, you can build and directly run your application with the following two commands:
- `dotnet build`
- `dotnet bin/Debug/netcoreapp2.1/dotnetbot.dll`
6. You can also try passing input to the sample to get the dotnet-bot to say something: `dotnet run dotnet-bot is a great teacher`
**Dockerize the application**
The Docker instructions are OS agnostic, however, the Dockerfile used relies on a Linux image.
7. Install the [Docker tools](https://www.docker.com/products/docker) for your operating system.
8. Build a Docker container, as specified by the [Dockerfile](Dockerfile): `docker build -t dotnetbot .`
9. Run the application in the container: `docker run dotnetbot Hello .NET Core from Docker`

View file

@ -1,8 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<OutputType>Exe</OutputType>
</PropertyGroup>
</Project>

View file

@ -1,12 +0,0 @@
using System;
namespace HelloWorldSample
{
public static class Program
{
public static void Main()
{
Console.WriteLine("Hello World!");
}
}
}

View file

@ -1,8 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<OutputType>Exe</OutputType>
</PropertyGroup>
</Project>

View file

@ -1,13 +0,0 @@
using System;
using System.Threading.Tasks;
namespace HelloWorldSample
{
public static class Program
{
public static async Task Main()
{
await Task.Run(() => Console.WriteLine("Hello World!"));
}
}
}

View file

@ -1,9 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<OutputType>Exe</OutputType>
<LangVersion>7.1</LangVersion>
</PropertyGroup>
</Project>

View file

@ -1,24 +0,0 @@
using System;
using System.IO;
namespace Qotd
{
public static class Program
{
public static void Main(string[] args)
{
if (args.Length == 0)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("You must specify a quotes file.");
Console.ResetColor();
return;
}
var quotes = File.ReadAllLines(args[0]);
var randomQuote = quotes[new Random().Next(0, quotes.Length - 1)];
Console.WriteLine($"[QOTD]: {randomQuote}");
}
}
}

View file

@ -1,8 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<OutputType>Exe</OutputType>
</PropertyGroup>
</Project>

View file

@ -1,56 +0,0 @@
We have a strange illusion that mere time cancels sin. But mere time does nothing either to the fact or to the guilt of a sin.
There can be no deep disappointment where there is not deep love.
My therapist told me the way to achieve true inner peace is to finish what I start. So far today, I have finished 2 bags of M&M`s and a chocolate cake. I feel better already.
Half a truth is often a great lie.
The survival of liberty in our land increasingly depends on the success of liberty in other lands.
The Constitution is not an instrument for the government to restrain the people, it is an instrument for the people to restrain the government -- lest it come to dominate our lives and interests.
From the prodigious hilltops of New Hampshire, let freedom ring. From the mighty mountains of New York, let freedom ring. From the heightening Alleghenies of Pennsylvania, let freedom ring. But not only that: Let freedom ring from every hill and molehill of Mississippi.
Without music, life would be a mistake.
Prosperity is the measure or touchstone of virtue, for it is less difficult to bear misfortune than to remain uncorrupted by pleasure.
The more you read about politics, you got to admit that each party is worse than the other.
Just the omission of Jane Austen`s books alone would make a fairly good library out of a library that hadn`t a book in it.
An unexciting truth may be eclipsed by a thrilling lie.
Beware how you take away hope from another human being.
Marriage is a duel to the death which no man of honour should decline.
If liberty and equality, as is thought by some, are chiefly to be found in democracy, they will be best attained when all persons alike share in government to the utmost.
Ignore death up to the last moment; then, when it can`t be ignored any longer, have yourself squirted full of morphia and shuffle off in a coma. Thoroughly sensible, humane and scientific, eh?
A good novel tells us the truth about its hero; but a bad novel tells us the truth about its author.
I have a dream that my four little children will one day live in a nation where they will not be judged by the color of their skin, but by the content of their character.
Take from the church the miraculous, the supernatural, the incomprehensible, the unreasonable, the impossible, the unknowable, the absurd, and nothing but a vacuum remains.
Power over a man`s subsistence is power over his will.
The puritanism of Christianity has played havoc with the moderation that an enlightened and tolerant critical spirit would have produced. I`ve noticed that in whatever country, county, town, or other region there is a regulation enjoining temperance, the population seems to be entirely composed of teetotallers and drunkards. There`s a Bible on that shelf there. But I keep it next to Voltaire - poison and antidote.
Never pick a fight with people who buy ink by the barrel.
There can be no liberty unless there is economic liberty.
Do not dwell in the past, do not dream of the future, concentrate the mind on the present moment.
If there were no God, there would be no Atheists.
It is impossible to travel faster than the speed of light, and certainly not desirable, as one`s hat keeps blowing off.
God is really only another artist. He invented the giraffe, the elephant and the cat. He has no real style, He just goes on trying other things.
Saturate yourself with your subject and the camera will all but take you by the hand.
Familiarity breeds contempt - and children.
Heaven have mercy on us all--Presbyterians and Pagans alike--for we are all dreadfully cracked about the head and desperately in need of mending.
The difference between Los Angeles and yogurt is that yogurt comes with less fruit.
I`m afraid that if you look at a thing long enough, it loses all of its meaning.
The difference between sex and death is that with death you can do it alone and no one is going to make fun of you.
Money buys you everything except the chance to do it again.
Never worry about the size of your Christmas tree. In the eyes of children, they are all thirty feet tall.
I think, at a child`s birth, if a mother could ask a fairy godmother to endow it with the most useful gift, that gift should be curiosity.
An unexamined life is not worth living.
It`s a phonetic language. Anything can make sense. How do you think Dr. Seuss wrote any of that sh*t?
Make everything as simple as possible, but not simpler.
There are lots of people who mistake their imagination for their memory.
We are what we repeatedly do. Excellence, therefore, is not an act, but a habit.
Wise men argue causes, and fools decide them.
A pint of sweat, saves a gallon of blood.
It ain`t the parts of the Bible that I can`t understand that bother me, it is the parts that I do understand.
A `geek` by definition is someone who eats live animals....I`ve never eaten live animals.
No virtuous act is quite as virtuous from the standpoint of our friend or foe, as from our own. Therefore, we are saved by the final form of love which is forgiveness.
The ladder of success is best climbed by stepping on the rungs of opportunity.
My best friend is the man who in wishing me well wishes it for my sake.
The best way to win an argument is to begin by being right.
Christmas is the gentlest, loveliest festival of the revolving year. And yet, for all that, when it speaks, its voice has strong authority.
Whenever science makes a discovery, the devil grabs it while the angels are debating the best way to use it.
Don`t you wish you had a job like mine? All you have to do is think up a certain number of words! Plus, you can repeat words! And they don`t even have to be true!
When angry, count ten before you speak; if very angry, a hundred.
People have a way of becoming what you encourage them to be, not what you nag them to be.
A man never tells you anything until you contradict him.
There are very few monsters who warrant the fear we have of them.

View file

@ -1,4 +1,4 @@
# Using Microsoft Xml Serializer Generator on .NET Core
# Using Xml Serializer Generator on .NET Core
Like the Xml Serializer Generator (sgen.exe) on desktop, Microsoft.XmlSerializer.Generator NuGet package is the solution for .NET Core and .NET Standard Libraries. It creates an Xml serialization assembly for types contained in an assembly to improve the startup performance of Xml serialization when serializing or de-serializing objects of those types using XmlSerializer.