-
Notifications
You must be signed in to change notification settings - Fork 378
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
Template fails dotnet restore after updating to dotnet core 2 preview 2 #1021
Comments
From @livarcocc on July 5, 2017 18:52 I don't see how this belongs in the CLI repo. We do not own the Fable templates. Should you move this bug to the fable repo? |
From @forki on July 5, 2017 18:57 No the problem is that the template source is fine. The template update process is somehow broken. |
From @livarcocc on July 5, 2017 18:57 We do not own this Paket.Restore.targets target. We do not know what it does. |
From @livarcocc on July 5, 2017 18:59 I see this in the targets:
It is up to the template owners to figure out why this is not being set properly anymore. @KevinRansom I wonder if this is due to preview2 moving to the new F# SDK? |
From @forki on July 5, 2017 19:7 Yes we do understand that you don't own these files. As far as we already know these files are all correct in the template source. And this has nothing to do with F# sdk or paket. |
From @KevinRansom on July 5, 2017 21:23 @forki In the section bellow: I believe PacketRootPath should be PacketToolsPath or vice-versa.
Edit when I set the path explicity, everything works as expected.
|
From @forki on July 6, 2017 6:32 @KevinRansom root path and tool path are two different things. The problem is not if paket can be called or not (that is just the symptom). Our issue is that we see dotnet new creating a wrong file. Again we think this has nothing to do with paket, f# or fable. It's just a matter of dotnet templating |
From @livarcocc on July 6, 2017 6:36 @mlorbetske can you take a look at this? have you heard about something like this before. @forki, so, the Paket.Restore.targets is not being generated at all? Because from @mike-morr initial bug report, it seemed like it did, but a property was missing, like @KevinRansom suggested. Are we sure we are talking about one single issue here? |
From @forki on July 6, 2017 6:44 Yes @mike-morr and myself discussed on gitter before we raised it. It's been investigated over couple of weeks. And since didn't find a solution we raised it here. |
From @forki on July 6, 2017 6:48 @KevinRansom can please diff your local version with the online version? The fact that path is wrong for you is probably due to the fact that the template creation bug reproed on your machine. |
From @livarcocc on July 6, 2017 7:18 Has the version with the problem ever been published? Did it even exist in your repo during some point in time? |
From @forki on July 6, 2017 7:22 I think it does not. There are 2 versions of that file. And IIRC my file after dotnet new was a mix of both. |
From @livarcocc on July 6, 2017 7:24 Ok, given that this seems like an issue with templates, I will let @mlorbetske investigate. if you want, go ahead and move this issue to dotnet/templating. |
@seancpeters can you take a look please? It looks like those targets files should be marked as copy only so that they don't get processed, we should provide instructions on how to do that |
@mike-morr the problem appears to be caused because during template creation, the default behavior is to process each file from the template source - to allow for optional / variable content in the output. Part of the processing identifies & evaluates conditional statements within each file, which may cause some content to be modified or excluded. But the default behavior can be overridden by configuration so that a file is simply copied, as opposed to being processed (and potentially modified). This is accomplished by adding the following to the template.json:
Note that the "copyOnly" value is an array, and so if there are other files which should just be copied, they can also be listed here. This is discussed in more detail at https://blogs.msdn.microsoft.com/dotnet/2017/04/02/how-to-create-your-own-templates-for-dotnet-new/ under the "Add optional content" heading. Please let us know if this takes care of your issue. |
My question would be: what in this file can lead to such damage? How can we make sure that other files are not messed up? This is also a much more general question than just for fable templates. The process needs to be transparent in order to be trusted. |
@seancpeters Thank you for the response! I have the same question as @forki |
@forki @mike-morr
Otherwise they behave the same as each other. Since it sounds as if you'd like your files to remain fully unmodified, it would make sense to put these near the start and end of the relevant files, something like this:
Regarding what is causing the target files to be different than the source files: The template engine has built-in support for conditional processing for many file types, and allows for custom setup for file types which aren't supported - and one can even override the built-in configurations as desired. For msbuild style files (*.*proj, *.*proj.user, *.msbuild, *.targets, and *.props) there is built in support for two ways to setup conditionals. One of these ways is to use the same conditional syntax as msbuild uses. The template engine decides whether to evaluate the conditional, or if it should be left alone and written to the target file without processing. Some of the conditions in your template caused the engine to choose incorrectly. We're working on a fix for this issue. As an example of using this style, the following file is part of a template currently maintained in this repo: https://github.com/dotnet/templating/blob/rel/vs2017/3-Preview3/template_feed/Microsoft.DotNet.Web.ProjectTemplates.2.0/content/WebApi-CSharp/Company.WebApplication1.csproj The other way looks like this (I can elaborate on this style if desired):
Please let me know if this made it clear what's actually going on, or if more clarification is needed. Our development work often gets ahead of the documentation. |
There's a second bug here that, despite the test that verifies it doesn't happen passing, unknown tokens are being accepted in string literals by the condition evaluator in msbuild files. So far I've managed to track this down to a condition where the trie evaluation driver needs to read past the end of the token (in this case That said, I'll echo @seancpeters's statement - if the file is intended to not be processed, it should be added to the set of copy-only files, speeding up the template generation time and ensuring that no evaluation is done on the file. Due to the current bug in the Include/Copy-Only/Exclude chaining (#1030 has been merged, so it'll be fixed in the upcoming release), the only option to get this working at this time is to turn off conditional processing for the file using the |
Thank you for detailed explanation. We were worried we see unexplainable behavior. But this makes sense. We're looking forward to a fix and will apply the workarounds to the various templates. Thank you! |
Both fixes will be included in the next release of the 2.0 CLI, closing this issue. Thanks for bringing this to our attention :) |
Wow. Cool. Thanks |
Thank you for the quick turnaround. I really appreciate it! |
From @mike-morr on July 5, 2017 18:1
Steps to reproduce
Install dotnet core
Install dotnet core 2 Preview 1
dotnet new -i Fable.Template
dotnet new fable -n TestProj
dotnet restore (should work)
Install dotnet core 2 Preview 2
dotnet new -i Fable.Template
dotnet new fable -n TestProj
dotnet restore
Expected behavior
dotnet restore succeeds the after installing Preview 2
Actual behavior
An error message is thrown:
Workaround
./.paket/paket.exe install
after this, dotnet restore works successfully.More Info
It appears like the paket restore targets are getting mangled somehow.
The source for the template is located here: https://github.com/fable-compiler/Fable/tree/master/src/templates/simple
Environment data
dotnet --info
output:Copied from original issue: dotnet/cli#7078
The text was updated successfully, but these errors were encountered: