Changes to the ProjectName from a Wizard is ignored

Hey GAT team!

I have a fairly simple project template that is running a recipe that helps the developer build the ProjectName for the new project. (among other things of course ;-)

The recipe contains the ProjectName argument, ie:

<Argument Name="ProjectName">
<ValueProvider Type="Evaluator" Expression="$(AppNamePrefix).Entities">
<
MonitorArgument Name="AppNamePrefix" />
</
ValueProvider>
</
Argument>

And allows the user to view / change it within the Wizard, ie:

<Fields>
<Field Label="Project Name" ValueName="ProjectName" />
</Fields>

Unfortunately upon wizard completion and unfolding of the project template, this name is ignored, and the original name entered in the "Add New" dialog is used instead.  I should note that the recipe does properly pickup and display the name entered in the "Add New" dialog when the wizard first comes up.  It just doesn't seem to accept any changes.

What am I doing wrong

Thanks in advance,




Answer this question

Changes to the ProjectName from a Wizard is ignored

  • nzwpfnewbie

    I suggest that for naming the project, you use as a starting point the ones provided by VS itself (at C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\ProjectTemplatesCache\CSharp\Windows\1033\ClassLibrary.zip, for example). There, you will see that they use the $safeprojectname$ for the project name. You should be able to define an argument with the same name, and use it in your templates, if you want to allow renaming via the wizard.

    However, I think it's best to leave it alone and use the value the user entered in the Add New dialog, which has that field exactly for that purpose. Asking for the same name twice would be confusing, IMO.



  • Quim88

    Hi Daniel - sorry for the delay in replying - been very busy stuffing myself with turkey and eggnog ;-)

    Hope you (and the rest of the GAT team) had a great holiday season.

    Now - onto the template:

    The following is the contents my Entities.vstemplate:

    <VSTemplate Version="2.0.0" Type="Project" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
    <
    TemplateData>
    <
    Name>ADE Entities Project</Name>
    <
    Description>ADE Entities Project</Description>
    <
    Icon Package="{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}" ID="4547" />
    <
    ProjectType>CSharp</ProjectType>
    <
    SortOrder>20</SortOrder>
    <
    CreateNewFolder>true</CreateNewFolder>
    <
    DefaultName>Entities</DefaultName>
    <
    ProvideDefaultName>true</ProvideDefaultName>
    </
    TemplateData>
    <
    TemplateContent>
    <
    Project File="Entities.csproj" ReplaceParameters="true">
    <
    ProjectItem ReplaceParameters="true">Properties\AssemblyInfo.cs</ProjectItem>
    <
    Folder Name="Classes"/>
    <
    Folder Name="Data"/>
    <
    Folder Name="XML"/>
    </
    Project>
    </
    TemplateContent>
    <
    WizardExtension>
    <
    Assembly>Microsoft.Practices.RecipeFramework.VisualStudio, Version=1.0.51206.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</Assembly>
    <
    FullClassName>Microsoft.Practices.RecipeFramework.VisualStudio.Templates.UnfoldTemplate</FullClassName>
    </
    WizardExtension>
    <
    WizardData>
    <
    Template xmlns="http://schemas.microsoft.com/pag/gax-template"
    SchemaVersion="1.0" Recipe="CreateEntityProject"/>
    </
    WizardData>
    </
    VSTemplate>

    Following is the recipe I'm using with the template:

    <Recipe Name="CreateEntityProject">
    <
    Types>
    <
    xi:include href="TypeAlias.xml" xmlns:xi="http://www.w3.org/2001/XInclude" xpointer="xmlns(gax=http://schemas.microsoft.com/pag/gax-core) xpointer(gax:Types/gax:TypeAlias)" />
    </
    Types>
    <
    Caption>Creates a new ADE Entities Project</Caption>
    <
    Arguments>
    <
    Argument Name="TopLevelNamespace">
    <
    Converter type="Microsoft.Practices.RecipeFramework.Library.Converters.NamespaceStringConverter, Microsoft.Practices.RecipeFramework.Library"/>
    </
    Argument>
    <
    Argument Name="AppNamePrefix">
    <
    Converter Type="Microsoft.Practices.RecipeFramework.Library.Converters.CodeIdentifierStringConverter, Microsoft.Practices.RecipeFramework.Library"/>
    </
    Argument>
    <
    Argument Name="ProjectName">
    <
    ValueProvider Type="Evaluator" Expression="$(AppNamePrefix).Entities">
    <
    MonitorArgument Name="AppNamePrefix" />
    </
    ValueProvider>
    </
    Argument>
    <
    Argument Name="RootNameSpace">
    <
    ValueProvider Type="Evaluator" Expression="$(TopLevelNamespace).$(AppNamePrefix).Entities">
    <
    MonitorArgument Name="AppNamePrefix" />
    <
    MonitorArgument Name="TopLevelNamespace"/>
    </
    ValueProvider>
    </
    Argument>
    </
    Arguments>
    <
    GatheringServiceData>
    <
    Wizard xmlns="http://schemas.microsoft.com/pag/gax-wizards" SchemaVersion="1.0">
    <
    Pages>
    <
    Page>
    <
    Title>ADE Entity Project Namespace and Application Prefix</Title>
    <
    LinkTitle>Project Information</LinkTitle>
    <
    Fields>
    <
    Field Label="Top Level Namespace" ValueName="TopLevelNamespace" />
    <
    Field Label="Application Name Prefix" ValueName="AppNamePrefix" />
    <
    Field Label="Project Name" ValueName="ProjectName" ReadOnly="true" />
    <
    Field Label="Fully Qualified Namespace" ValueName="RootNameSpace" ReadOnly="true" />
    </
    Fields>
    </
    Page>
    </
    Pages>
    </
    Wizard>
    </
    GatheringServiceData>
    </
    Recipe>

    and last but not least is the Entities.csproj where I'm trying to use the ProjectName argument:

    <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <
    PropertyGroup>
    <
    Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <
    Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <
    ProductVersion>8.0.50727</ProductVersion>
    <
    SchemaVersion>2.0</SchemaVersion>
    <
    ProjectGuid>$guid1$</ProjectGuid>
    <
    OutputType>Library</OutputType>
    <
    AppDesignerFolder>Properties</AppDesignerFolder>
    <
    RootNamespace>$RootNameSpace$</RootNamespace>
    <
    AssemblyName>$ProjectName$</AssemblyName>
    </
    PropertyGroup>
    <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <
    DebugSymbols>true</DebugSymbols>
    <
    DebugType>full</DebugType>
    <
    Optimize>false</Optimize>
    <
    OutputPath>bin\Debug\</OutputPath>
    <
    DefineConstants>DEBUG;TRACE</DefineConstants>
    <
    ErrorReport>prompt</ErrorReport>
    <
    WarningLevel>4</WarningLevel>
    <CodeAnalysisRules>-Microsoft.Design#CA1020;-Microsoft.Design#CA1031;-Microsoft.Design#CA1032;-Microsoft.Design#CA1033;-Microsoft.Naming#CA1718;-Microsoft.Naming#CA1720;-Microsoft.Naming#CA1700;-Microsoft.Naming#CA1712;-Microsoft.Naming#CA1713;-Microsoft.Naming#CA1709;-Microsoft.Naming#CA1708;-Microsoft.Naming#CA1715;-Microsoft.Naming#CA1710;-Microsoft.Naming#CA1707;-Microsoft.Naming#CA1722;-Microsoft.Naming#CA1711;-Microsoft.Naming#CA1716;-Microsoft.Naming#CA1705;-Microsoft.Naming#CA1725;-Microsoft.Naming#CA1719;-Microsoft.Naming#CA1721;-Microsoft.Naming#CA1706;-Microsoft.Naming#CA1724;-Microsoft.Naming#CA1726</CodeAnalysisRules>

    <RunCodeAnalysis>false</RunCodeAnalysis>
    </
    PropertyGroup>
    <
    PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <
    DebugType>pdbonly</DebugType>
    <
    Optimize>true</Optimize>
    <
    OutputPath>bin\Release\</OutputPath>
    <
    DefineConstants>TRACE</DefineConstants>
    <
    ErrorReport>prompt</ErrorReport>
    <
    WarningLevel>4</WarningLevel>
    <
    CodeAnalysisRules>-Microsoft.Design#CA1020;-Microsoft.Design#CA1031;-Microsoft.Design#CA1032;-Microsoft.Design#CA1033;-Microsoft.Naming#CA1718;-Microsoft.Naming#CA1720;-Microsoft.Naming#CA1700;-Microsoft.Naming#CA1712;-Microsoft.Naming#CA1713;-Microsoft.Naming#CA1709;-Microsoft.Naming#CA1708;-Microsoft.Naming#CA1715;-Microsoft.Naming#CA1710;-Microsoft.Naming#CA1707;-Microsoft.Naming#CA1722;-Microsoft.Naming#CA1711;-Microsoft.Naming#CA1716;-Microsoft.Naming#CA1705;-Microsoft.Naming#CA1725;-Microsoft.Naming#CA1719;-Microsoft.Naming#CA1721;-Microsoft.Naming#CA1706;-Microsoft.Naming#CA1724;-Microsoft.Naming#CA1726</CodeAnalysisRules>
    <
    RunCodeAnalysis>false</RunCodeAnalysis>
    </
    PropertyGroup>
    <
    ItemGroup>
    <
    Reference Include="System" />
    <
    Reference Include="System.Data" />
    <
    Reference Include="System.Xml" />
    </
    ItemGroup>
    <
    ItemGroup>
    <
    Folder Include="Classes\" />
    <
    Folder Include="Data\" />
    <
    Folder Include="XML\" />
    </
    ItemGroup>
    <
    ItemGroup>
    <
    Compile Include="Properties\AssemblyInfo.cs" />
    </
    ItemGroup>
    <
    Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
    <!--
    To modify your build process, add your task inside one of the targets below and uncomment it.

    Other similar extension points exist, see Microsoft.Common.targets.

    <Target Name="BeforeBuild">

    </Target>

    <Target Name="AfterBuild">

    </Target>
    -->

    <ProjectExtensions>
    <
    VisualStudio>
    <
    UserProperties ProjectCreatedByADEWizard="True" />
    </
    VisualStudio>
    </
    ProjectExtensions>
    </
    Project>

     

    Thanks,

    Roy



  • Jay B. Harlow

    Can you paste the source for your .vstemplate


  • MollyBos - MSFT

    Did my .vstemplate source help

    Still having issues getting this to work properly.  I managed to get a bit of a work around going by tossing in a "RenameProject" action into the recipe, but this isn't ideal as its still creating the project inside a subfolder whose name is coming from the project name entered in the "Add New Project" dialog.

     

    Would it be possible to post a sample that illustrates how to add a project with a project name specified by and argument within the recipe

    Thanks,



  • Changes to the ProjectName from a Wizard is ignored