Hi together!
I am currently lost with a quite trivial problem: read arguments from a recipe
My motivation is to create a strong-name key file. All necessary information to create the file comes from the user. Therefore I use my CreateSolution recipe where I want to use an action called AddStrongNameKey.
Within the recipe I defined two arguments: KeyFileName and SnToolPath (the path to the sn.exe file). Both are used as input variables for my AddStrongNameKey action.
I can rebuild and register the package without any problem but as far as I create a new solution and it has to execute my custom action my vs instance stops to work.
Where is my mistake?! I bound the action to the CreateSolution recipe and defined the variables within the action correctly.
It would be great if someone could give me a hint on that.
Thanks a lot!
Cheers,
Tom
Find my CreateSolution recipe code below:
| <Recipe |
| Name="CreateSolution" |
| xmlns="http://schemas.microsoft.com/pag/gax-core" |
| xmlns:xi="http://www.w3.org/2001/XInclude"> |
| <Caption>Collectsinformationforthenewsamplesolution.</Caption> |
|
| <Arguments> |
| <ArgumentName="KeyFileName"Type="System.String"Required="true"/> |
| <ArgumentName="SnToolPath"Type="System.String"Required="true"/> |
| <!--<ArgumentName="WebSiteName"> |
| <ConverterType="Microsoft.Practices.RecipeFramework.Library.Converters.NamespaceStringConverter,Microsoft.Practices.RecipeFramework.Library"/> |
| </Argument>--> |
| </Arguments> |
| <GatheringServiceData> |
| <Wizardxmlns="http://schemas.microsoft.com/pag/gax-wizards"SchemaVersion="1.0"> |
| <Pages> |
| <Page> |
| <Title>BSoptFactoryConfiguration</Title> |
| <Fields> |
| <FieldLabel="KeyFileName"ValueName="KeyFileName"/> |
| <FieldLabel="SnToolPath"ValueName="SnToolPath"/> |
| <!--<EditorType="System.Windows.Forms.Design.FolderNameEditor,System.Design,Version=2.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a"/>--> |
| <!--</Field>--> |
| </Fields> |
| </Page> |
| </Pages> |
| </Wizard> |
| </GatheringServiceData> |
|
| <Actions> |
| <ActionType="MyFactory.Actions.AddStrongNameKey, MyFactory" |
| Name="AddStrongNameKey"> |
| <InputName="KeyFileName"RecipeArgument="KeyFileName"/> |
| <InputName="SnToolPath"RecipeArgument="SnToolPath"/> |
| </Action> |
| </Actions> |
| </Recipe> |
My custom action called AddStrongNameKey looks like this:
| publicclassAddStrongNameKey:Action |
| { |
| privatestringkeyFileName; |
|
| [Input(Required=true)] |
| publicstringKeyFileName |
| { |
| get{returnthis.keyFileName;} |
| set{this.keyFileName=value;} |
| } |
|
| privatestringsnToolPath; |
|
| [Input(Required=true)] |
| publicstringSnToolPath |
| { |
| get{returnthis.SnToolPath;} |
| set{this.snToolPath=value;} |
| } |
|
| publicoverridevoidExecute() |
| { |
| DTEvs=this.GetService<DTE>(true); |
|
| //GettheSoultionItemspathandthekeyfilepath... |
| stringsolutionPath=(string)vs.Solution.Properties.Item("Path").Value; |
| stringsolutionDir=Path.GetDirectoryName(solutionPath); |
| stringsolutionItemsDir=Path.Combine(solutionDir,"SolutionItems"); |
| stringkeyFilePath=Path.Combine(solutionItemsDir,this.KeyFileName); |
|
| //Checkifsn.exewascorrectlyprovidedbytheuser... |
| stringsnPath=Path.Combine(this.SnToolPath,"sn.exe"); |
|
| MessageBox.Show("KeyFilePath",keyFilePath); |
| MessageBox.Show("SolutionItemsDir",solutionItemsDir); |
|
| //if(!File.Exists(snPath)) |
| //thrownewInvalidOperationException("Couldnotfindsn.exeinthespecifiedfolder"+this.snToolPath+"!"); |
| } |
|
| publicoverridevoidUndo() |
| { |
| thrownewNotImplementedException(); |
| } |
| } |