VS2017 Solution Template Structure - visual-studio-2017

I have generated a VS (multi-) project template which I am having trouble trying to control the base hierarchy structure when it is used.
The template source folder/full solution has the following projects
MyTemplate.UI
MyTemplate.BusinessLogic
MyTemplate.DataModels
MyTemplate.Helpers
MyTemplate.Interfaces
MyTemplate.Services.APIConnector
MyTemplate.Services.AuthProvider_AAD
The .vstemplate file is
<VSTemplate Version="2.0.0" Type="ProjectGroup" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
<TemplateData>
<Name>IoC Template</Name>
<Description>Template with IoC/project separation</Description>
<Icon>Icon.ico</Icon>
<ProjectType>CSharp</ProjectType>
</TemplateData>
<TemplateContent>
<ProjectCollection>
<ProjectTemplateLink ProjectName="$safeprojectname$.UI" CopyParameters="true">
MyTemplate.UI\MyTemplate.vstemplate
</ProjectTemplateLink>
<ProjectTemplateLink ProjectName="$safeprojectname$.BusinessLogic" CopyParameters="true">
MyTemplate.BusinessLogic\MyTemplate.vstemplate
</ProjectTemplateLink>
<ProjectTemplateLink ProjectName="$safeprojectname$.DataModels" CopyParameters="true">
MyTemplate.DataModels\MyTemplate.vstemplate
</ProjectTemplateLink>
<ProjectTemplateLink ProjectName="$safeprojectname$.Helpers" CopyParameters="true">
MyTemplate.Helpers\MyTemplate.vstemplate
</ProjectTemplateLink>
<ProjectTemplateLink ProjectName="$safeprojectname$.Interfaces" CopyParameters="true">
MyTemplate.Interfaces\MyTemplate.vstemplate
</ProjectTemplateLink>
<SolutionFolder Name="$safeprojectname$.Services" CopyParameters="true">
<ProjectTemplateLink ProjectName="$safeprojectname$.APIConnector" CopyParameters="true">
MyTemplate.Services.APIConnector\MyTemplate.vstemplate
</ProjectTemplateLink>
<ProjectTemplateLink ProjectName="$safeprojectname$.AuthProvider_AAD" CopyParameters="true">
MyTemplate.Services.AuthProvider_AAD\MyTemplate.vstemplate
</ProjectTemplateLink>
</SolutionFolder>
</ProjectCollection>
</TemplateContent>
</VSTemplate>
Now, when then solution/project is created, everything deploys as expected, however, it always seems to insert an additional folder level from the base folder...
So, lets say I want to create a project call WidgetProject, in VS2017, File-> New -> Project, select the template and set the following
Name = WidgetProject
Location = C:\WorkProjects
Solution name = WidgetProject
Create directory for solution = ticked
What this then generates as a folder structure is
C:\MyProjects\WidgetProject\WidgetProject.sln
WidgetProject\WidgetProject.UI
WidgetProject\WidgetProject.BusinessLogic
WidgetProject\WidgetProject.BusinessLogic
WidgetProject\WidgetProject.DataModels
WidgetProject\WidgetProject.Helpers
WidgetProject\WidgetProject.Interfaces
WidgetProject\WidgetProject.Services\APIConnector
WidgetProject\WidgetProject.Services\AuthProvider_AAD
All of the project folders are an extra layer deep... I want to put them at the same folder level as the .sln file.
I am sure it is just a simple setting in the .vstemplate file, but i just cant figure it out.
TYIA

Unfortunate but when you create a new project based on your template, there is a setting "Place solution and project in the same directory" in the dialog screen.
As it looks like there is no way to control this from the template definition.
All you can do: you can write a comment into your description node of project (or project group) definition, that you are preferring that specific setting for your solution...

Related

Item Template for VSTemplate file

I'm trying to create VS Item Template that will allow adding .vstemplate files to project.
This is how my vsTemplate.vstemplate file currently looks:
<?xml version="1.0" encoding="utf-8"?>
<VSTemplate
xmlns:sdk="http://schemas.microsoft.com/developer/vstemplate-sdkextension/2010"
xmlns="http://schemas.microsoft.com/developer/vstemplate/2005"
Version="3.0.0"
Type="Item">
<TemplateData>
<Name>VS Item Template</Name>
<Icon>vsTemplate.ico</Icon>
<Description>VS Item Template Files</Description>
<DefaultName>vsTemplate</DefaultName>
<ProjectType>CSharp</ProjectType>
<TemplateID>Microsoft.CSharp.Class</TemplateID>
<CreateInPlace>true</CreateInPlace>
</TemplateData>
<TemplateContent>
<ProjectItem TargetFileName="Template\$fileinputname$.vstemplate" ReplaceParameters="true">vsTemplate.data</ProjectItem>
<ProjectItem TargetFileName="Template\$fileinputname$.$fileinputextension$.data">vsTemplate.empty.data</ProjectItem>
<ProjectItem TargetFileName="Template\$fileinputname$.ico">vsTemplate.ico.data</ProjectItem>
</TemplateContent>
</VSTemplate>
When I am trying to use it (inside vs experimental instance), I am getting this error:
The system cannot find the file specified. (Exception from HRESULT: 0x80070002)
How I understand the problem, I need to specify custom build action for .vstemplate file inside .csproj file, something like this:
<VSTemplate Include"..."/>
But I don't know how to do that.
What I'am already tried:
set ItemType="VSTemplate" for vstemplate ProjectItem
use custom Wizard class
add /log option inside project command line argument window (it does not provide any additional information)

Symfony1 template defaults and fallbacks or template sharing between modules

I work on a Symfony1 application.
For part of the application we use the symfony admin generator which builds default actions and templates for a particular module.
The autogenerated action methods can be overridden in the child action class and the templates can be overridden, by making one with the same name in the module's template folder.
Local templates are used instead of the autogenerated ones, which are stored in a cache folder (I assume this is normal symfony behaviour).
apps/
my_app
modules/
post/
actions/
actions.class.php
lib/
templates/
...
cache/
my_app/
environment/
modules/
autoPostcd /
actions/
actions.class.php
lib/
templates/
indexSuccess.php
_part_1.php
_part_2.php
I am currently working on a separate application that is not using the admin generator.
But I have 3 modules that do very similar things, that I would like to share.
I have all 3 actions extending the same custom action class so that they all implement the same methods and share the ones that are identical.
The problem that I am having is sharing the templates.
The main templates and most of the partials can be reused as is.
apps/
other_app/
lib/
printingActions.class.php
modules/
ticket/
actions/
actions.class.php
lib/
templates/
printSuccess.php //exactly the same for all 3
_part_1.php
_part_2.php //exactly the same for all 3
_part_3.php
receipt/
actions/
actions.class.php
lib/
templates/
printSuccess.php //exactly the same for all 3
_part_1.php
_part_2.php //exactly the same for all 3
_part_3.php
voucher/
actions/
actions.class.php
lib/
templates/
printSuccess.php //exactly the same for all 3
_part_1.php
_part_2.php //exactly the same for all 3
_part_3.php
What I would like to do is pull out the common ones so that each module and any future modules with a similar interface, only have to have the partials with module specific information.
This would be my ideal setup:
apps/
other_app/
lib/
printingActions.class.php
printingCommonTemplates/
printSuccess.php //exactly the same for all 3
_part_2.php //exactly the same for all 3
modules/
ticket/
actions/
actions.class.php
lib/
templates/
_part_1.php
_part_3.php
receipt/
actions/
actions.class.php
lib/
templates/
_part_1.php
_part_3.php
voucher/
actions/
actions.class.php
lib/
templates/
_part_1.php
_part_3.php
I know this kind of thing can be done, since the admin generator does it, but after hours of digging, I can't find where exactly it does it.
Could someone point me in the right direction for this one?
Ideally, if there is a fallback template setting that I can set for a particular module or a filter class that I can extend to do what I need?
If you want to use a common module action class with a default layout you can use the following approach:
class printingActions extends sfActions {
public function preExecute() {
$this->setLayout('print_success_common');
}
public function executeIndex() {
}
}
Then in your module action you may have:
class ticketActions extends printingActions
{
public function executePrint(sfWebRequest $request)
{
$this->txt = 1234;
return $this->renderPartial('part_1', array('txt' => $this->txt));
}
}
You can use a different(common) layout from your action by using:
class ticketActions extends printingActions
{
public function executePrint(sfWebRequest $request)
{
$template = $this->getContext()->getConfiguration()->getTemplateDir('printing', 'print_success_common_alt.php');
$this->setLayout($template . '/print_success_common_alt');
...
$this->txt = 1234;
return $this->renderPartial('part_1', array('txt' => $this->txt));
}
}
I found a partial solution, to at least be able to share templates.
In the Partials section of the docs for symfony1, it mentions that there are 3 places that you can call partials from:
From the current module
From a different module in the same application
From the global template folder for the current application
So, what I can do is put the common partials in a single place and reference them from each of the modules that need to use them.
I can also pass in a variable with the current modules name, so that it can call module specific templates from within the common ones, dynamically.
I considered putting the common partials directly in the global template directory, but it would get messy and confusing if there were more than one type of module that did this.
The awkward work around was to create a directory inside the template directory, which I could put these files in.
apps/
other_app/
lib/
printingActions.class.php
modules/
ticket/
actions/
actions.class.php
lib/
templates/
printSuccess.php //common parts extracted to partial
_part_1.php
_part_3.php
receipt/
actions/
actions.class.php
lib/
templates/
printSuccess.php //common parts extracted to partial
_part_1.php
_part_3.php
voucher/
actions/
actions.class.php
lib/
templates/
printSuccess.php //common parts extracted to partial
_part_1.php
_part_3.php
templates/
_printing_common/
print_success_common.php //common parts of PrintSuccess extracted as partial
part_2.php //exactly the same for all 3
It created a less than ideal problem, of having to underscore the new directory and remove the underscore from the partials inside.
But, using this method I was able to share the common bits and have the module specific code be the only thing that needed to be specified in the module template directories.
Here is an example of the contents of some of these files:
apps/other_app/modules/ticket/templates/printSuccess.php
<?php
include_partial(
'global/printing_common/print_success_common',
array(
'moduleNameText' => $moduleNameText
)
);
apps/other_app/templates/_printing_common/print_success_common.php
...
<?php include_partial($moduleNameText.'/part_1',array('moduleNameText' => $moduleNameText)); ?>
...
<?php include_partial('global/printing_common/part_2',array('moduleNameText' => $moduleNameText)); ?>
...
<?php include_partial($moduleNameText.'/part_3',array('moduleNameText' => $moduleNameText)); ?>
This is not the ideal solution, so I will leave this question open to a better solution, but they is my work around until then.

Using Mixins with Foundation 5

I've just installed Foundation 5 with Sass and am using Compass to watch my stylesheets. I wanted to know what's the best practice for adding my custom styles. I've already created a custom.scss file and am referencing it using #import "custom"; in my app.scss file.
If I wanted to go ahead and change the background colour of the body, for example, how would I go about doing this using the mixins. I'm adding:
$body-bg: red;
to my custom.scss file, but the body's background isn't changing. Should I just edit the _settings.scss file, that seems wrong...
Any idea what I'm doing wrong? Thanks in advance!
Here's my config.rb:
# Require any additional compass plugins here.
add_import_path "bower_components/foundation/scss"
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "stylesheets"
sass_dir = "scss"
images_dir = "images"
javascripts_dir = "javascripts"
# You can select your preferred output style here (can be overridden via the command line):
# output_style = :expanded or :nested or :compact or :compressed
# To enable relative paths to assets via compass helper functions. Uncomment:
# relative_assets = true
# To disable debugging comments that display the original location of your selectors. Uncomment:
# line_comments = false
# If you prefer the indented syntax, you might want to regenerate this
# project again passing --syntax sass, or you can uncomment this:
# preferred_syntax = :sass
# and then run:
# sass-convert -R --from scss --to sass sass scss && rm -rf sass && mv scss sass
In your case maybe would be better use these structure:
app.scss:
#import "custom"; //where you define variables for foundation such as $body-bg: red;
#import "foundation";
#import "other styles";
Yes, I've always just edited the _settings.scss file -- then use a decent file comparison (like Araxis Merge or Kaleidoscope to merge in new options as updates are made). If I have custom variables, I'll stick those at the top of the settings file (that need to effect both the settings and my global stuff after the fact).

Gradle multi-project, change default build filename (build.gradle)

We have a multiproject with a settings.gradle and no build.gradle in the root project.
The default behaviour of gradle is just look up the settings.gradle file on the top dir and read the build.gradle for every project defined before.
My problem is: depending on the environment where the multiproject has been checked out, I want to run as default "build2.gradle" instead of "build.gradle" when running a build from the root project.
What is the best way to do it??
Thanks
Or for nested multiproject in settings.gradle:
setBuildFileName(rootProject)
def setBuildFileName(project) {
project.children.each { childProject ->
childProject.buildFileName = "${childProject.name}.gradle"
assert childProject.projectDir.isDirectory()
assert childProject.buildFile.isFile()
setBuildFileName(childProject)
}
}
ok, done...
In settings.gradle:
String myFileName = "build2.gradle"
rootProject.buildFileName = myFileName
rootProject.children.each { project ->
project.buildFileName = myFileName
assert project.projectDir.isDirectory()
assert project.buildFile.isFile()
}

EXTRA_DIST for Makefile.am repeats the directory name

I'm using EXTRA_DIST within a Makefile.am to copy some folders:
EXTRA_DIST = input/
The problem is that it repeats the directory name input/input/
Do you know any solution for this problem? is this a bug of automake?
I have found the solution. With: "EXTRA_DIST = input" instead of "EXTRA_DIST = input/" works fine