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

Added project template #9

Closed
wants to merge 41 commits into from
Closed

Added project template #9

wants to merge 41 commits into from

Conversation

shweaver-MSFT
Copy link
Member

@shweaver-MSFT shweaver-MSFT commented Dec 7, 2021

Fixes #4

Template folder:
image

Visual Studio Solution Explorer:
image

Example output from dotnet new labsapp -n TemplateTest
image

I put together a simple project template with most of the parts that should make a good baseline for starting new labs projects. CounterButton is a custom button that increments when you click it. I figure this is a nice opportunity to show a few common patterns for creating templated controls.

Unit and UI Tests

All the tests work, including UI tests using WinAppDriver.

Documentation

The ProjectTemplate.md represents the documentation for the feature (it will be renamed during the generation process).

I've also included a README.md to cover the various parts of the template and how to use it.

dotnet new

To install the template for use from dotnet new, go to the Template directory and run the following command:

dotnet new --install ./

Once the template is installed, use the dotnet new command to generate a new copy of the template with a provided name:

cd C:/Git
dotnet new labsapp -n MyLabsApp

Let me know what you think!

TODO:

  • Add more comments to explain the code and project requirements.
  • Update READMEs with guidance and tips
  • Add file headers
  • Add the UI Test application
    • See if we can add a dev dependency NuGet or something to install WAD and pre-build launch so F5 on UI Tests works out-of-box with template?
    • Enable UI tests to work in CI Docs (Added as separate item to Setup CI Infrastructure #13)
  • Enable generation with dotnet new
  • Enable generation with VSIX template (Packaging a template with multiple projects and solution items is not supported)
  • Create PowerShell script to run the basic template commands
    • newexperiment.ps:
    • Accepts name parameter to pass to dotnet new
    • Auto installs the template if not already
    • Generates new folder in the /Labs directory
    • Note: Batch is not compatible with codespaces, but PS is.
  • Move CounterButton template to own resource file and link to Generic.xaml
  • Use assets and config from root/Common folder via relative links from the root/Labs folder

@michael-hawker
Copy link
Member

michael-hawker commented Dec 7, 2021

We can worry about ui tests later too? They're not as common, as I think we can get away a lot with the VisualUITestBase (we should bring that over to the common folder to be able to reference in our unit test projects).

I guess when the template is copied/used for setup in the Labs directory, it'd replace 'CounterButton' automatically with whatever the name of the experiment is?

@shweaver-MSFT
Copy link
Member Author

shweaver-MSFT commented Dec 7, 2021

@michael-hawker you bring up an interesting point. I put the CounterButton in there expecting the dev to strip it out and rename the projects. The process of doing that will show them everywhere they need to update with their own code. I didn't plan on doing any auto renaming.

The other approach is to put no examples in the template, leave it bare, and expect the dev to follow the comments.

I lean towards option 1 because it gives them something to use as an example, and if we ever detect "CounterButton" we know there is more work to do.

@michael-hawker
Copy link
Member

michael-hawker commented Dec 7, 2021

@shweaver-MSFT yeah, I do like having example code that does something that they can modify. I just know sometimes it can be hard to get every namespace and config thing (especially in some project files) when it comes to renaming things, so it'd be cool if the template setup step could do that bit for them. We could leave the component in the library file still called 'CounterButton'. I think it'd just be all the project names and things.

This would also make sure it's less likely they dev doesn't change the library namespace/package name that we'd still want to follow the pattern of CommunityToolkit.Labs.Uwp.ExperimentName (or maybe we want Windows over UWP as it may target Uno and eventually WinUI or something as well, we haven't gotten to that point yet though).

@shweaver-MSFT
Copy link
Member Author

@michael-hawker I agree, some auto-replacement of names would be nice. I made a few changes. Let me know what you think. @Arlodotexe @XAML-Knight you guys too!

@shweaver-MSFT
Copy link
Member Author

@XAML-Knight sorry you hit those issues with the template. @michael-hawker brought up a good idea about encapsulating the setup in a newexperiment.bat file. I'll spend some time setting up the script to handle all the dotnet new bits. You're right, we shouldn't expect devs to need to know the CLI to spit out a template 🙂

@michael-hawker
Copy link
Member

Looks like this branch is really far behind main and is missing common things you'll need.

I think the goal here was to just get the infrastructure setup and explore some of the testing bits, then we could coordinate better with everything merged together.

Though it looks like Shane may have merged main in at least.

I think we do need to test if the template is happy of we reference a props file that wouldn't exist in the template directory until the template is created, though again think we can fix and explore that after we know what our final sample environment looks like.


# Does an experiment by this name already exist in the Labs folder?
# If so, we'll need to re-prompt for the experiment name and re-validate until the name is determined to be unique.
while (Test-Path "./Labs/$($ExperimentName)" -PathType Container)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want a loop or to just terminate the command and they can just run it again with a different name?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I vote for terminating so it's easier to integrate with other tooling

MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Documentation", "Documentation", "{3D695A5F-0860-46E0-B52F-5C80F692617A}"
ProjectSection(SolutionItems) = preProject
..\..\License.md = ..\..\License.md
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This path goes to a file that may not be available in the generated solution as it isn't in the template and relies on the new solution being created in a specific location.

@@ -0,0 +1,21 @@
# Windows Community Toolkit Labs - Project Template
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the purpose of this file?
Is it documenting the code that is then packaged into a template?
Or, is it intended to explain the generated solution to the developer who created a new lab from the template?

If the first, why is it in the generated solution?

If the second, it needs actionable content. It would also be good to have this open by default when the solution is opened for the first time.

In either case, it would be useful to have some placeholder content in each section that indicates what will eventually go under each heading.

@shweaver-MSFT
Copy link
Member Author

JFYI, I don't have any intentions of working on this PR anymore. It was a fun hackathon project, but I had a hard time completing it without more clarity around what the requirements are for this template feature. @michael-hawker you can do with this what you like :)

@mrlacey would you be interested in taking this on and working with Michael to find the right template pattern?

@mrlacey
Copy link
Contributor

mrlacey commented Mar 17, 2022

JFYI, I don't have any intentions of working on this PR anymore. It was a fun hackathon project, but I had a hard time completing it without more clarity around what the requirements are for this template feature. @michael-hawker you can do with this what you like :)

@mrlacey would you be interested in taking this on and working with Michael to find the right template pattern?

Thanks.
I started making a few comments as I was looking through it before realizing there were bigger things going on that would likely prevent this from being merged. :)

@michael-hawker michael-hawker marked this pull request as draft March 17, 2022 18:09
@michael-hawker
Copy link
Member

JFYI, I don't have any intentions of working on this PR anymore. It was a fun hackathon project, but I had a hard time completing it without more clarity around what the requirements are for this template feature. @michael-hawker you can do with this what you like :)

Thanks @shweaver-MSFT! This is going to be super useful for the future. We've just been figuring out where everything is going to land, so want to make sure we create the template bit after we know how everything fits together. Matt just joined our team here, so he's digging into all this stuff as we shore up what our requirements are and move forward.

@michael-hawker
Copy link
Member

Superseded by #76, closing this out now. Thanks @shweaver-MSFT for all this early investigation work!

@niels9001 niels9001 deleted the shweaver/template branch June 22, 2023 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Template Infrastructure
5 participants