locked
How to get Obfuscated Build(Smart Assembly 5) into Drop Folder(TFS 2010) RRS feed

  • Question

  • Hi,

    I've been tasked with obfuscating and auto building our projects. I have the two working great independant of one another, but I need to find a way to get the obfuscated build into the drop folder set in TFS2010.

    In my .vbproj file my MSBuild code looks like this:

    <PropertyGroup> <PostBuildEvent>"C:\Program Files\Red Gate\SmartAssembly 5\smartassembly.com" /build "$(ProjectDir)DBManager.saproj" /markasreleased </PostBuildEvent> </PropertyGroup>

    The problem is it's building the unobfuscated code and putting it into the drop folder.

    Im using the DefaultTmplate.xaml as my build process file. Is this possible or will I manually need to create a script to transfer the obfuscated assembly(.exe) to the drop folder i've set in TFS2010?

    Any ideas would be greatly appreciated!

    Friday, February 18, 2011 9:43 PM

Answers

  • I installed TFS and Smart Assembly. I figured out that you don't need to use the postbuild condition nor update the BuildTemplate. You need to update the project file to with the smart assembly target. TFS team build overrides the outputPath with OutDir veriable. My code below overrides the unobfuscated files with the obfuscated ones.

    I am assuming that you don't need to run unit test and test impacts analysis as I was getting warnings. I disabled them in my team build definition.

    For more info, check

    http://www.red-gate.com/supportcenter/Content?p=SmartAssembly&c=SmartAssembly/help/5.0/SA_UsingSmartAssemblyWithMSBuild.htm&toc=SmartAssembly/help/5.0/toc1032253.htm

    Follow these steps and if you need more info don't hesitate to ask. Cheers

    Right Click on the project --> Unload project
    Right click on the project--> Edit project

    If you are using VB, after the following line:

    <Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
    
    

    Add

     <UsingTask TaskName="SmartAssembly.MSBuild.Tasks.Build" AssemblyName="SmartAssembly.MSBuild.Tasks, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7f465a1c156d4d57" />
    
     <Target Name="BeforeBuild" Condition=" '$(Configuration)' == 'Release' ">
    
      <CreateProperty Value="true">
    
       <Output TaskParameter="Value" PropertyName="RunSmartAssembly"/>
    
      </CreateProperty>
    
     </Target>
    
     <Target Name="AfterBuild" Condition=" '$(RunSmartAssembly)' != '' ">
    
       <SmartAssembly.MSBuild.Tasks.Build ProjectFile="SmartAssemblyPOC.saproj" 
                        input="$(OutDir)SmartAssemblyPOC.exe"
                        output="$(OutDir)SmartAssemblyPOC.exe"
                        OverwriteAssembly="true" 
                        MarkAsReleased="true"/>
    
     </Target>
    
    
    

    Ahmed is an independent consultant in Ottawa, Canada specialized in .NET, Biztalk, WCF, WPF, TFS and other Microsoft technologies. Blog: http://lajak.wordpress.com Twitter: ahmedalasaad
    Thursday, February 24, 2011 4:03 AM
  • Hi,

    Lajak's help was very useful in getting though this issue. I am now able Autobuild and have the output copied over to the TFS Drop Folder. I've achieved this using the following code in the .vbproj file:

    <Import Project="$(MSBuildBinPath)\Microsoft.VisualBasic.targets" />
      <UsingTask TaskName="SmartAssembly.MSBuild.Tasks.Build" AssemblyName="SmartAssembly.MSBuild.Tasks, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7f465a1c156d4d57" /> 
      <PropertyGroup>
        <PostBuildEvent>"C:\Program Files\Red Gate\SmartAssembly 5\smartassembly.com" /build "$(ProjectDir)DBManager.saproj" /output="$(OutDir)DBManager.exe" /markasreleased </PostBuildEvent>
      </PropertyGroup>

    I was not setting the "OutDir" to the /output file. If someone could please point me to a listing of all the possible TFS/VS tokens to use OutDir, ProjectDir that would be extremely helpful moving forward.

    Thanks again to everyone that helped me!

    Thursday, February 24, 2011 4:37 PM

All replies

  • You need to modify the template. I have blogged how to build btdfproj files. You want to modify the condition to build saproj files and use "invoke process" activity instead of the msbuild

    http://lajak.wordpress.com/2011/02/19/build-biztalk-deployment-framework-projects-using-tfs2010/

    In my blog, I am not leaving the assemblies in the bin folder at the source directory and don't copy them to the drop folder. I have a part two of the post which copies the binaries into the binaries folder and the drop folder. I will post it this week.


    An independent consultant in Ottawa, Canada specialized in .NET, Biztalk, WCF, WPF, TFS and other Microsoft technologies. Blog: http://lajak.wordpress.com
    Monday, February 21, 2011 5:42 AM
  • Hi lbargers,

     

    Thanks for your post.

     

    Have you took Lajak’s solution?

     

    According your description, you said that find a way to get the obfuscated build into the drop folder set in TFS2010, do you mean that you want copy files form sources to drop location?

     

    If I misunderstand you, please provide more detailed information or example to explant your scenario.


    John Qiao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, February 21, 2011 10:13 AM
    Moderator
  • Hi lbargers,

     

    What about the progress for this issue?


    John Qiao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, February 22, 2011 7:54 AM
    Moderator
  • Hi John,

    I have just returned from vacation and I am looking into Lajak Tech's response today. As far as your question. I simply want to find a way to automate a build copying the Obfuscated output(.exe) into the drop folder that I have set in TFS. The automated build is currently working correctly, but the obfuscated .exe is not getting copied across.

    Thanks

    Wednesday, February 23, 2011 3:40 PM
  • I installed TFS and Smart Assembly. I figured out that you don't need to use the postbuild condition nor update the BuildTemplate. You need to update the project file to with the smart assembly target. TFS team build overrides the outputPath with OutDir veriable. My code below overrides the unobfuscated files with the obfuscated ones.

    I am assuming that you don't need to run unit test and test impacts analysis as I was getting warnings. I disabled them in my team build definition.

    For more info, check

    http://www.red-gate.com/supportcenter/Content?p=SmartAssembly&c=SmartAssembly/help/5.0/SA_UsingSmartAssemblyWithMSBuild.htm&toc=SmartAssembly/help/5.0/toc1032253.htm

    Follow these steps and if you need more info don't hesitate to ask. Cheers

    Right Click on the project --> Unload project
    Right click on the project--> Edit project

    If you are using VB, after the following line:

    <Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
    
    

    Add

     <UsingTask TaskName="SmartAssembly.MSBuild.Tasks.Build" AssemblyName="SmartAssembly.MSBuild.Tasks, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7f465a1c156d4d57" />
    
     <Target Name="BeforeBuild" Condition=" '$(Configuration)' == 'Release' ">
    
      <CreateProperty Value="true">
    
       <Output TaskParameter="Value" PropertyName="RunSmartAssembly"/>
    
      </CreateProperty>
    
     </Target>
    
     <Target Name="AfterBuild" Condition=" '$(RunSmartAssembly)' != '' ">
    
       <SmartAssembly.MSBuild.Tasks.Build ProjectFile="SmartAssemblyPOC.saproj" 
                        input="$(OutDir)SmartAssemblyPOC.exe"
                        output="$(OutDir)SmartAssemblyPOC.exe"
                        OverwriteAssembly="true" 
                        MarkAsReleased="true"/>
    
     </Target>
    
    
    

    Ahmed is an independent consultant in Ottawa, Canada specialized in .NET, Biztalk, WCF, WPF, TFS and other Microsoft technologies. Blog: http://lajak.wordpress.com Twitter: ahmedalasaad
    Thursday, February 24, 2011 4:03 AM
  • Hi lbargers,

     

    Thanks for your reply.

     

    After you tired Lajak’s solution, please share the result here.


    John Qiao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, February 24, 2011 10:13 AM
    Moderator
  • Hi,

    Lajak's help was very useful in getting though this issue. I am now able Autobuild and have the output copied over to the TFS Drop Folder. I've achieved this using the following code in the .vbproj file:

    <Import Project="$(MSBuildBinPath)\Microsoft.VisualBasic.targets" />
      <UsingTask TaskName="SmartAssembly.MSBuild.Tasks.Build" AssemblyName="SmartAssembly.MSBuild.Tasks, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7f465a1c156d4d57" /> 
      <PropertyGroup>
        <PostBuildEvent>"C:\Program Files\Red Gate\SmartAssembly 5\smartassembly.com" /build "$(ProjectDir)DBManager.saproj" /output="$(OutDir)DBManager.exe" /markasreleased </PostBuildEvent>
      </PropertyGroup>

    I was not setting the "OutDir" to the /output file. If someone could please point me to a listing of all the possible TFS/VS tokens to use OutDir, ProjectDir that would be extremely helpful moving forward.

    Thanks again to everyone that helped me!

    Thursday, February 24, 2011 4:37 PM
  • I am glad that I was able to help. It seems that you have the OutDir in the MSBUILD activity set to "", otherwise smartassembly.com won't find the required assembly.

     

    In regards to the MSBUILD and TFS properties:

    Check this post out http://keithbloom.wordpress.com/2010/09/13/tfs-and-msbuild-properties/

     

    Cheers

    Ahmed

     

     


    Ahmed is an independent consultant in Ottawa, Canada specialized in .NET, Biztalk, WCF, WPF, TFS and other Microsoft technologies. Blog: http://lajak.wordpress.com Twitter: ahmedalasaad
    Friday, February 25, 2011 1:34 AM
  • For other people's benefit, I blogged about the steps I used

    http://lajak.wordpress.com/2011/03/05/tfs2010-use-red-gate-smartassembly-in-automated-team-build-to-obfuscate-assemblies/


    Ahmed is an independent consultant in Ottawa, Canada specialized in .NET, Biztalk, WCF, WPF, TFS and other Microsoft technologies. Blog: http://lajak.wordpress.com Twitter: ahmedalasaad
    Sunday, March 6, 2011 4:13 AM