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

Issue with location of Dockerfile when using template #34

Open
mlorbetske opened this issue Jun 12, 2018 · 7 comments
Open

Issue with location of Dockerfile when using template #34

mlorbetske opened this issue Jun 12, 2018 · 7 comments

Comments

@mlorbetske
Copy link
Member

From @LeighF51 on June 5, 2018 15:59

Hi,

I have a template with 3 projects (one of them being a docker project) that are setup in a template. When creating a new solution from the template the docker file in my service project is included but it is stored away in a set of folders rather than being left at the root of the project it should be part of.

I've tried including a copyOnly section in my template.json but it doesn't seem to work with the DockerFile.

{
  "author": "Author",
  "classifications": [],
  "description": "Service Package Template, generates a set of projects that can be bundled up into a nuget package for service usage",
  "name": "Service Template (.NET Core)",
  "defaultName": "Test",
  "identity": "Sample.Template.CSharp",
  "groupIdentity": "Sample.Template",
  "tags": {
    "language": "C#",
    "type": "project"
  },
  "shortName": "NetCoreServiceTemplate",
  "sourceName": "NetCoreServiceTemplate",
  "guids": [
	"{05DCBF2B-411C-45E0-B5F2-7E8E3120670F}",
	"{73E50470-2CD5-4CD0-89CB-E54FA997F56B}"
  ],
  "primaryOutputs": [
    {
      "path": "TestServiceTemplate\\TestServiceTemplate.csproj"
    },
	{
      "path": "TestServiceTemplateLibrary\\TestServiceTemplateLibrary.csproj"
    }
  ],
  "sources": [
	{
		"include":[
			"**/*"
        ],
		"exclude": [
			"**/[Tt]estServiceTemplateVsix/**",
			"**/*.sln",
			"**/.template.config/**"
		],		
		"copyOnly": [
			"**/DockerFile"
		]
	}  
  ]
}

image
As the image above shows the window on the left displays the path where the file gets stored when creating a solution using the template and the one on the right shows the root of the project where the dockerfile should be based on the location it was at in the template.

I'm not sure if the issue with the dockerfile being stored elsewhere is due to it not having an extension?
Is there a way of me controlling where this file gets stored to in the projects generated from a template?

Copied from original issue: dotnet/templating#1551

@mlorbetske
Copy link
Member Author

From @seancpeters on June 5, 2018 23:54

Could you post some info on the directory structure of your template source, including:

  • the fully expanded path to the docker file in the source
  • the location of the template.json file

The existence or lack of a file extension shouldn't affect the output location of any files.

@mlorbetske
Copy link
Member Author

From @LeighF51 on June 6, 2018 7:16

@seancpeters

In the source the dockerfile can be found at the root of the service template project i.e. C:\Users\fyfieldl\source\Templates\ServiceTemplate\NetCore\NetCoreServiceTemplate - from here I have the dockerfile, csproj etc
image

This structure for the docker file can also be seen in the template in the solution view
image

The template.json file is stored one directory up from the service template itself (as it's a multi project template) inside the .template.config folder
image
image

Hope this is enough info

@mlorbetske
Copy link
Member Author

From @seancpeters on June 8, 2018 21:26

@LeighF51 - I'm going to need to play with a copy of your template to figure out what's going on. Is the template source in a repo where I can download it?

Also, are you invoking this template only from VS, or also using "dotnet new"?

@mlorbetske
Copy link
Member Author

From @LeighF51 on June 11, 2018 9:50

@seancpeters

You can find a version of the template at https://github.com/LeighF51/ServiceTemplate

Only invoking the template from VS, not using dotnet new at all

@mlorbetske
Copy link
Member Author

Taking a look at the nupkg generated when building the solution in the repo, it looks like the docker file is being placed at a different location than expected.

To get the behavior you expect, the file would need to be located at
Content\NetCoreServiceTemplate\Dockerfile

But it's actually located here instead
Content\NetCoreServiceTemplate\Dockerfile\NetCoreServiceTemplate\Dockerfile

It looks like this is being done as part of the SideWaffle build process (nothing's jumping out as being a customization that'd have this effect), I'll move this issue to that repo.

@rsaltrelli
Copy link

rsaltrelli commented Jan 23, 2019

I'm encountering this same problem. Seems to be because Dockerfile has no file extension. If I rename it to Dockerfile.txt then the problem goes away. What is the resolution/workaround for this?

@revealyan
Copy link

revealyan commented Nov 3, 2021

my Dockerfile doesn't copy to template
workaround
1)rename Dockerfile -> Dockerfile.d
2)add the parameter

"RenameDocker": {
            "type": "parameter",
            "datatype": "text",
            "fileRename": "Dockerfile.d",
            "defaultValue": "Dockerfile"
}

3)hide the parameter in dotnetcli.host.json or ide.host.json

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

No branches or pull requests

3 participants