ligershark / side-waffle

A collection of Item- and Project Templates for Visual Studio
Other
657 stars 205 forks source link

System.ArgumentException: Illegal characters in path #377

Closed Bobisback closed 8 years ago

Bobisback commented 8 years ago

As per the comment "FYI it's better to raise issues like this in the SideWaffle repo because we have more eyes on that repo. If there." by sayedihashimi I am posting this question in this repo as well even thought it is a issue in template builder.

Hello,

I would not consider this a issue as it is probably my lack of knowledge that is causing the problem.

I am trying to setup a mutiproject template using sidewaffle and template builder. I am using a combination of these two tutorials (I think they are made by the same person lol): https://www.youtube.com/watch?v=z33jOo75CH4 and https://github.com/ligershark/side-waffle/wiki/How-to-create-a-multi-project-template. When I am building the VISX project I get the following exception:

The "GetItemTemplateNameFromVSTemplatePath" task failed unexpectedly. System.ArgumentException: Illegal characters in path. at System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional) at System.Security.Permissions.FileIOPermission.QuickDemand(FileIOPermissionAccess access, String fullPath, Boolean checkForDuplicates, Boolean needFullPath) at System.IO.FileInfo.Init(String fileName, Boolean checkHost) at System.IO.FileInfo..ctor(String fileName) at LigerShark.TemplateBuilder.Tasks.GetItemTemplateNameFromVSTemplatePath.Execute() at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext()

Any ideas what might be causing this and how to troubleshoot it. I guess a messed up path name is a good guess. Just not sure where to start. As a side note I used the same project to make a mutiproject solution template using this method: https://www.jayway.com/2015/03/13/visual-studio-how-to-create-a-solution-template-with-multiple-projects/. And it worked fine was just not very maintainable. Hence why I am trying this approach.

Any help would be appreciated as this is my first template I am trying to create. I just need a nudge in the right direction.

Thanks, Bob

sayedihashimi commented 8 years ago

@Bobisback thanks for posting this.

Multi-project templates are very tricky with the current support. I'm working on a new way to create templates, and it simplifies the multi-project story significantly. I haven't integrated this into SideWaffle yet but I will soon.

Here's my proposal. I'll help you get your multi-project template setup with my new method. After I set it up, it will be super easy for you to maintain and if you run into any issues I'll help you. I'll also explain everything that I did so that you understand what's happening. What I ask of you, after you're satisfied that I've delivered on my promise, is to help write up some docs in the wiki so that others can redo what we did together. That way I can help you, and the entire community gets the benefit. It enables me to scale better. I've done this before in the past and it's worked well.

Bobisback commented 8 years ago

Sure sounds good. I do however need to make sure this template I am building is kept in confidence. I am not in a position to release it publicly. Let me know the best way to contact you and we can get started on what is needed.

Thanks, Bob

P.S Keep in mind this is a fairly complicated template I am building hahaha. I just had to start out on super hard mode lol. So it may be a bit tricky to get up and running on top of the already trickiness.

sayedihashimi commented 8 years ago

@Bobisback ok no problem. I can actually set up a skeleton for you and then you can help me fill in the replacement values. You can keep the project content private. How many projects are you creating here? I'll create a sample with the same number of projects.

Bobisback commented 8 years ago

I will be building 8 projects in this one template.

sayedihashimi commented 8 years ago

@Bobisback OK, I'm going to create a new repo with a sample that uses 8 projects. Then I'll explain what everything is. Then you can change it up for your project and I'll help you along the way.

Bobisback commented 8 years ago

Ok cool sounds good.

sayedihashimi commented 8 years ago

@Bobisback OK try this vsix at https://ci.appveyor.com/project/sayedihashimi/pecan-waffle-samples/build/artifacts. You should see a new node in File->New Project named Pecan Waffle and then a multi-project template. Make sure that you can create the projects and that they build fine on your box.

The repo for this is at https://github.com/sayedihashimi/pecan-waffle-samples

If they do follow these steps to replace with your own content.

old instructions

new instructions

Most of the content of pw-templateinfo.ps1 is straight forward. Let me know if you have questions on it. For the guid part you can run

Get-ChildItem .\templates *.*proj -Recurse -File|Select-Object -ExpandProperty fullname -Unique|% { ([xml](Get-Content $_)).Project.PropertyGroup.ProjectGuid|Select-Object -Unique|%{ '({0}, {{"$ProjectId"}}, [System.Guid]::NewGuid(),@("*.*proj")),' -f $_ }}

You'll need to update the format of the guid to match what's in the script already though.

Then build the .vsix, install it and see if your templates show up. We can meet on Skype to discuss questions and for me to explain what's happening in more details after you are past go.

Bobisback commented 8 years ago

This sounds good. I have not had a chance to do this yet. Will probably be tonight or tomorrow at the latest when I can get to this. The only concern I have is this: "You should see a new node in File->New Project named Pecan Waffle and then a multi-project template. Make sure that you can create the projects and that they build fine on your box." So first off this may just be a misunderstanding with wording on my part so please let me know. This statement makes it sound like I will be creating a project template for each project. Then you want me to make sure that I can create a new project with that template and then build it on my machine?

If this understanding is correct then I got a bit of a issue. All the projects have to reference at least one other project in the solution template. So they will not compile in this case. Is this fine or is there something I am missing?

Thanks, Bob

sayedihashimi commented 8 years ago

So first off this may just be a misunderstanding with wording on my part so please let me know. This statement makes it sound like I will be creating a project template for each project.

No, it's one entry point in the New Project Dialog which then creates several projects. Essentially a "solution template".

The sample I have creates 8 projects at once, and there are references between each project.

Bobisback commented 8 years ago

Ok cool. Thanks for the clarification. I think I understand now. I will take a stab at this tonight.

Thanks, Bob

sayedihashimi commented 8 years ago

@Bobisback ok great, looking forward to it. After you get setup you'll be able to add more mulit-project (or single project) templates easily by adding another folder + the two files listed above.

Bobisback commented 8 years ago

Alright I am working on this now. I started the template that you added with the extension and it built fine. I am following your steps I will inform you if I have any issues.

Bobisback commented 8 years ago

@sayedihashimi I am not sure what the following is used for or if I need to replace it with something relevant to my projects.

`

<CustomParameters xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
  <CustomParameter Name="TemplateName" Value="ContosoZebra" />
  <CustomParameter Name="PecanWaffleInstallBranch" Value="dev" />
  <CustomParameter Name="Item" Value="Item" />
</CustomParameters>

`

This is in the _project.vstemplate file.

Bobisback commented 8 years ago

@sayedihashimi I am not sure what you mean by this "Change the Id attribute of the Identity element at PecanWaffleSamplesVs/source.extension.vsixmanifest to a new unique value." Currently I have the repo cloned on my computer and I deleted everything besides _project.vstemplate and pw-templateinfo.ps1. Where does this id element come in at? Where is it located? Do I need to create it? Did I miss a step?

sayedihashimi commented 8 years ago

@Bobisback sorry I think the instructions were not very clear.

I updated the samples to have a new template setup. All you have to do is drop in your files.

Let's start over with the instructions, I updated them inline above. I've pasted them here as well.

Bobisback commented 8 years ago

Do I have to setup a vstemplate file for each project as well or is there some automagic going on in the background that will do what needs to be done?

I should have some free time tonight to give this a shot.

Thanks, Bob

sayedihashimi commented 8 years ago

No, just add your source files. Then customize the two files already there.

Bobisback commented 8 years ago

Ok got it build and installed. One thing to note when I ran the "Find the guid part" it found way more then 8 GUID's and I am not sure what the other ones where. Also in the output of the project when it built there was a couple of exceptions thrown.

1> TemplateAdd-Replacement : Cannot process argument transformation on parameter 1> 'defaultValue'. Cannot convert the "6829829e-fc47-474e-83b8-7bf1fba75d4c" 1> value of type "System.Guid" to type "System.Management.Automation.ScriptBlock".

I am guessing this is related to this "You'll need to update the format of the guid to match what's in the script already though." When I start the template I get a similar exception. I will continue to work on it.

Thanks, Bob

Oh lol that is what you mean. Put them in quotes. I get it standby. Still not sure what to do about the extra guid's.

Bobisback commented 8 years ago

@sayedihashimi Ok got the project to build with no errors. I just started VS and created a new project with the template I just made. It said it was created successfully, but it would appear that visual studio locked up. It also occurs to be that I need a crash course in building visual studio extensions haha. I am not sure how to start the experimental VS instance.

sayedihashimi commented 8 years ago

Delete the extra guids.

Bobisback commented 8 years ago

How do I know which ones are the extra ones or can I just delete the last 3 or 4. Just make sure 8 are there?

P.S I just went into each project and got the guid. I am rebuilding it now.

sayedihashimi commented 8 years ago

Delete the guid ones that were in the script previously. Replace with guid values from your .proj files. The snippet provided can be used to construct the lines to add. Make sure to fix quotes and remove trailing comma.

Bobisback commented 8 years ago

@sayedihashimi It is still saying visual studio is busy and just sits there once i create the template. I did replace the guids that where originally in the template file. When I ran your command to get the project guids it gave me back 14 guids, not 8. Even though there are only 8 projects. So I went into each project manually and got the guid for them. This did not seem to help as it is still locking up. Might be skype time :p

sayedihashimi commented 8 years ago

Can you email me your pw-templateinfo.ps1 file? sayedha at Microsoft(dot)com. I'll take a look for any issues.

sayedihashimi commented 8 years ago

Also including your _project.vstemplate file will be helpful as well.

Bobisback commented 8 years ago

Done, you can edit out your email if you want.

Bobisback commented 8 years ago

@sayedihashimi I cannot get this to work again. I updated my project and moved it into the pecan waffle project. I rebuilt the project with no changes reflected in the extension. Cleaning and rebuilding did not seem to help. After some investigation I found that the obj folder was not being cleared so it was not pulling the new changes. So after deleting that folder and rebuilding it seemed to clear that issue up.

Unfortunately though now when I try to select the template in visual studio I am getting an exception that on project creation reads:

System.ApplicationException: TemplateName is null at PecanWaffle.ProjectWizard.RunFinished()

Any ideas?

Thanks, Bob

Bobisback commented 8 years ago

@sayedihashimi Ummmm so it turns out for some reason the following lines where deleted from my _project.vstemplate:

`

  <CustomParameter Name="PecanWaffleInstallBranch" Value="dev" />
  <CustomParameter Name="ExtensionId" Value="PecanWaffleSamplesVs.ecdc6243-592e-499f-9867-458f2fa4a056"/>
  <CustomParameter Name="Item" Value="Item" />
</CustomParameters>`

So this seemed to fix the TemplateName issue. Now though I am getting a runtime exception. Error is a bit to big so going to post a screenshot of this one.

screen shot 2016-05-24 at 9 59 53 pm

Once you click ok this one comes up next.

screen shot 2016-05-24 at 10 00 02 pm

Any ideas?

Thanks, Bob

sayedihashimi commented 8 years ago

Did you follow the steps in my video http://youtu.be/ysvTROB963k?

Also if you installed the NuGet pkg and are having issues make sure you are using the latest prerelease NuGet pkg for "pecan-waffle" and "pecan-waffle-vs". When installing it would be good to overwrite the .props file to ensure you have latest content. I removed some items from that file.

sayedihashimi commented 8 years ago

If you are using what we worked on a few weeks back, just get rid of that and follow steps in video. You can save and reuse the .vstemplate and pw-templateinfo.ps1 files.

Bobisback commented 8 years ago

Ya I got it working now. I was using hte old way. Great video! Sorry I missed it.

Thanks for all the work you have done.