Giter Club home page Giter Club logo

dotnet-template-samples's Introduction

.NET Template Samples

This repository contains samples of templates created using the Template Engine. Custom templates can be used from dotnet new today. We are working on integrating these templates into Visaul Studio as well.

For more general info on dotnet new, and the Template Engine, see the following.

Contributing

We would love community contributions here.

See CONTRIBUTING.md for information on contributing to this project.

This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behavior in our community. For more information, see the .NET Foundation Code of Conduct.

License

This project is licensed with the MIT license.

Related Projects

You should take a look at these related projects:

dotnet-template-samples's People

Contributors

guardrex avatar patridge avatar sayedihashimi avatar simoncropp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dotnet-template-samples's Issues

Question: Are project-scoped single-file scaffolders supported?

Hello,

I understand that customising existing templates is possible by using the /Templates/ folder at the root of a project. This permits overriding the generated code for templates that already exist.

But does it support adding completely new .cshtml files (e.g.: the 'DanGenerator' folder in the first screenshot, with the 'DanController.cshtml' and 'DanView.cshtml' files) and then using those?

I'm having trouble figuring this out, and there's a few unanswered Stack Overflow questions pertaining to this.
However the documentation in this GitHub repository seems to be concerned only with scaffolding entire project templates.

image

These screenshots depict what I'm aiming to achieve:

image

image

Thank you for your help.

Kind regards,
Daniel

Cannot find setup.cmd or setup.sh

Both links in the README are 404, and I can't find the files anywhere in the repo.

Has the installation process for dotnet new3 changed?

Expression/Condition in parameter default value

Is there a way to make a parameter defaultValue conditional/based on an expression?

I want to have


		"fileToRename": {
			"type": "parameter",
			"datatype": "string",
                        "defaultValue": "if(boolParam) then TheSpecialFile.txt else TheFile.txt",
			"replaces": "TheFile.txt",
			"fileRename": "TheFile.txt"
		},

Any sample of templating to generate just files?

Creates a solution file:

dotnet new sln

From looking at the source this also supports other args. I can't find where dotnet new sln is:

dotnet new sln add -MyProject

Can you make a template that can act as just a generator for files? Or like the above you would need something like a COnsole app to invoke from.

I would like to create a dotnet new for generating classes and others.

make basic samples smaller

The first samples (basic, etc) is a copy of aspnet web template.
While is good, there are lot of useless files, is really hard to understand what's needed for THE TEMPLATE, and what's there just because is an aspnet core app.

These are the first templates you read, and are really complex.

Is possibile to use normal (hello world) console app an lib there too?

Handling optional project ref in .sln files?

I'm looking to use dotnet new to help template both old VS solutions and new dotnet type projects.

See also: VS Solution File

When manipulating an .sln for inclusion of OPTIONAL projects (i.e. giving the user the option for sub projects such as Foo.Data/Foo.Data.csproj) the .sln file would need its references updated/omitted.

In yeoman/npm

In yeoman/npm this is handled with inline code.

	GlobalSection(ProjectConfigurationPlatforms) = postSolution<% for(var project in projects) { %>
		{<%= projects[project].projectGuid %>}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{<%= projects[project].projectGuid %>}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{<%= projects[project].projectGuid %>}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{<%= projects[project].projectGuid %>}.Release|Any CPU.Build.0 = Release|Any CPU<% } %>

Feature Request: VS templating

Please provide an example of how the templates can be installed using VSIX and integrated/used from within VisualStudio 2017 & 2019; file->new project etc. including adding templates to the ASP.NET Core Web Application dialog

Packaging templates as a nupkg

I'm not aware of any documentation and/or samples on how to package up a group of templates as a nupkg (though we do have documentation on actually installing from a nupkg in the dotnet/templating README).

Add an example of the state of the art on how to create a package from template dir

Is possibile to create package the template in lot of ways (nuget, nuspec, csproj, prj)

The best one i know atm is doing just with a .proj (any extension is ok), like https://github.com/fable-compiler/Fable/blob/master/src/templates/simple/Fable.Template.proj

so like Fable.Template.proj (note the .proj extension, neutral, not csproj, so doesnt mess with compiler targets)

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>

    <!-- fill some nuget package props (optional) -->
    <Description>Simple Fable App</Description>
    <Authors>Alfonso Garcia-Caro</Authors>
    <!-- fill nuget package version (optional) -->
    <Version>0.2.1</Version>

    <!-- this is a package -->
    <PackageType>Template</PackageType>

    <!-- cruft need to avoid building and making dotnet sdk happy -->
    <PackProjectInputFile>$(MSBuildProjectFullPath)</PackProjectInputFile>
    <NoBuild>true</NoBuild>
    <IncludeBuildOutput>false</IncludeBuildOutput>
    <TargetFramework>netstandard1.0</TargetFramework>
    <DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>

  </PropertyGroup>
  <PropertyGroup>
    <!-- simple way to exclude things (optional but nice) -->
    <ExcludeFromPackage>
        Content/node_modules/**/*;
        Content/packages/**/*;
        Content/public/bundle.js*;
        Content/bin/**/*;
        Content/obj/**/*;
    </ExcludeFromPackage>
</PropertyGroup>
  <ItemGroup>
    <Content Include="Content/**/*" Exclude="$(ExcludeFromPackage)" >
        <PackagePath>Content\</PackagePath>
    </Content>
  </ItemGroup>
</Project>

Best way to handle symbols in packages.config.

Problem

I need to be able to optionally add/remove NuGet packages from a project based on a symbol's value. I would love if we had a sample that accomplished this, as I think it's a somewhat-common ask of a templating engine.

Potential Solutions

Outside of having multiple packages.config, what is a sufficient solution? You can't really markup a packages.config with symbols if you want the project to still be able to restore NuGets when opened.

Q: parameter regexpr

Is it possible for a template parameter value to have a regex validation attached to prevent/validate the values supplied; an or display a validation error if/when the value supplied violates the regex condition?

If so can you please point towards references/samples?

How to create a nuget package with a multiple project template

Hi,

I'm creating a template with 2 projects (src and test) and would like to publish this as a nuget package.
I understand that it is easy modifying the .csproj adding the nuget config, but what about the whole solution directory?

Here is how my template base folder looks like:

src (webapi project)
terraform
tests (xunit project)
.dockerignore
.editorconfig
.gitignore
.template.config
azure-pipelines-pr.yml
azure-pipelines.yml
MySolution.sln
README.md

`dotnet new -i` fails when I try to point to filesystem

  1. Clone the repo
  2. cd dotnet-template-samples/01-basic-template/MyProject.Con
  3. dotnet new -i .

Fails to install the template, just gives me about a hundred lines of warnings like:

Restoring packages for /Users/user1/.templateengine/dotnetcli/v2.0.3/scratch/restore.csproj...
/usr/local/share/dotnet/sdk/2.0.3/NuGet.targets(102,5): warning : The folder '/usr/local/share/dotnet/sdk/NuGetFallbackFolder/.tools' contains an invalid version. [/Users/user1/.templateengine/dotnetcli/v2.0.3/scratch/restore.csproj]

and then at the end it gives me the error:

/Users/user1/.templateengine/dotnetcli/v2.0.3/scratch/restore.csproj : error NU1101: Unable to find package .. No packages exist with this id in source(s): /usr/local/share/dotnet/sdk/NuGetFallbackFolder, nuget.org
  Generating MSBuild file /Users/user1/.templateengine/dotnetcli/v2.0.3/scratch/obj/restore.csproj.nuget.g.props.
  Generating MSBuild file /Users/user1/.templateengine/dotnetcli/v2.0.3/scratch/obj/restore.csproj.nuget.g.targets.
  Restore failed in 596.09 ms for /Users/user1/.templateengine/dotnetcli/v2.0.3/scratch/restore.csproj.

This repros on both Windows and macOS for me.

compy386:MyProject.Con user1$ dotnet --info
.NET Command Line Tools (2.0.3)

Product Information:
 Version:            2.0.3
 Commit SHA-1 hash:  eb1d5ee318

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.12
 OS Platform: Darwin
 RID:         osx.10.12-x64
 Base Path:   /usr/local/share/dotnet/sdk/2.0.3/

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.3
  Build    : a9190d4a75f4a982ae4b4fa8d1a24526566c69df

Custom Assembly Name

I want to prefix my namespace with some custom namespaces e.g. Template.MyProject (where Template is automatically replaced with the project name) when created with the name Test and with parameter "namespacePrefix" being CompanyName, the project would be Test.MyProject but the namespace would be CompanyName.Test.MyProject

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.