Competition: What’s your favorite Redgate tool? Enter now.

FR: project includes

Uniwares_ASUniwares_AS Posts: 168
edited June 29, 2010 2:50PM in SmartAssembly 5
Feature Request: include for project settings

Having about 30 SA project files to maintain for a single solution (and there are much larger ones out there) its a real pain to either hand edit each one or even worse, modify it with the GUI app.

How nice would it be to be able to do something like
<Include File="solutionwideassemblies.{sa}inc" />
where the .{sa}inc file contains my list of assemblies references and settings used in all my SA projects for this solution.
I understand that this cant be managed by the GUI app anymore (at least not with acceptable effort) but who uses MSBuild doesn't care much about this anyway.
Same could be applied to the <Options> section, settings like <Company>, etc.
Would make life for larger solutions a lot easier.

Comments

  • You can try to use the Input option when calling SA. Then you can use the same file. I am trying something like this on my build server:
    &lt;SmartAssembly.MSBuild.Tasks.Build ProjectFile="$&#40;DeploymentRoot&#41;\CommonFile.saproj"
             Input="$&#40;DeploymentRoot&#41;\Target1.dll"
             OverwriteAssembly="True"
             MarkAsReleased="True" /&gt;
    &lt;SmartAssembly.MSBuild.Tasks.Build ProjectFile="$&#40;DeploymentRoot&#41;\CommonFile.saproj"
             Input="$&#40;DeploymentRoot&#41;\Target2.dll"
             OverwriteAssembly="True"
             MarkAsReleased="True" /&gt;
    
    _Ed_
  • While its a bit like carrying the church around the cross, it might work. Will give it a try.
  • Ok, gave it a try but got stuck on an bad error message.

    ERROR: Some options are not set or are not valid.
    Please review all the settings and try again.


    The options themselves cant be wrong since they are copied from a 100% working project file. The GUI app asks for an input and output file and builds fine. No errors.

    What did I do? Added all the assemblies of all libraries (around 30) which I am going to protect to the project file and call the commandline app with the -input parameter which is one of the assemblies in the project.
  • Paul.MartinPaul.Martin Posts: 83 New member
    Are you specifying an -output parameter as well?
  • Paul.MartinPaul.Martin Posts: 83 New member
    The full list of things which will give that error:
    • It can not find the main assembly as specified by the -input parameter or if -input is not given, the one in the project file. (The input parameter should either be an absolute path or a path relative to the project file name. Note it is not relative to the current working directory)
    • There is not a destination file name specified, either by the -output parameter or by the project file.
    • If you have asked to sign you assembly with a strong named key and the strong name key file does not exist.
    • If you are using the Automatic Error Reporting feature with a custom reporting template and it can not find the template specified or it is invalid.
    • If the project file specifies that one or more assemblies should be merged, but are not referenced by the main assembly.

    My guess is either the second or the last are the problem.

    Yes it would be better if SA actually told you what part of the configuration it was having problems with.
  • Ok, using the -output parameter it works on the commandline. Yet trying to do the same with the build task fails in all combinations. With and without the output parameter, overwrite yes or no, all the same, it fails and I dont get the error message because its a build task and MSBuild shows only that SA exited with error code -1.
  • Paul.MartinPaul.Martin Posts: 83 New member
    Do you use a logger with MSBuild (e.g. http://msdn.microsoft.com/en-us/library/ms171470%28VS.80%29.aspx)?

    The SmartAssembly.MSBuild.Task is configured to log errors and the errors from the actual build process will be sent to the log, although you may need to set the verbosity level to normal or detailed.


    My guess if it works fine with the standalone command line, then it is a permissions or relative path issue.
  • As I am not using MSBuild.exe but devenv.exe to build the executables I dont get the error output from SA into the VS error console.

    I can try MSBuild but I recently had problems with the configuration of the msbuild process so this may take some time to setup right.
  • Paul.MartinPaul.Martin Posts: 83 New member
    OK, if you go into Visual Studio (which ever edition you are building under) and under the "Tools" menu select "Options".
    Under the "Projects and Solutions" section choose "Build and Run". You can then set the "MSBuild project build output verbosity" to one of the high settings.

    There is a registry setting to do the same (e.g. if you can't run the IDE) HKCU\Software\Microsoft\VisualStudio\9.0\General
    DWORD key "MSBuildLoggerVerbosity" with data "4" (diagnostic) or "3" (detailed), but usual warnings about editing your registry.


    If you are building using the IDE version you will get all the detail straight-away. If you are using the command line version you should add the switch
    /out <log file name>
    to view the information (N.B. this is an append only log and with diagnostic will get quite big very quickly so turn off logging and reduce the verbosity as soon as you sort out the problem).
  • Thanks Paul, that was a great tip. But makes me wonder why doesn't SA at least log errors by default to the console? Digging through miles of log is not the funniest.

    Anyway, solved the problem now, it was really a wrong path to the input assembly (should have been $(ProjectDir)\obj\Release and not $(TargetDir)), SA threw an IOException.

    So this makes this workaround somehow usable. Although a <Include> would be much cleaner and logical.

    If someone else is interested, this is what the SA output looks like:
    Target "AfterCompile: &#40;TargetId:36&#41;" in file "X:\solutionfolder\SmartAssembly.targets" from project "X:\solutionfolder\project\subproject\subproject.csproj" &#40;target "Compile" depends on it&#41;:
    Task "Copy" &#40;TaskId:17&#41;
      Copying file from ".\obj\Release\subproject.dll" to ".\obj\Release\subproject.temp.dll". &#40;TaskId:17&#41;
    Done executing task "Copy". &#40;TaskId:17&#41;
    Task "SmartAssembly.MSBuild.Tasks.Build" &#40;TaskId:18&#41;
      Command: &#40;TaskId:18&#41;
      C:\Program Files\Red Gate\SmartAssembly 5\SmartAssembly.com "X:\solutionfolder\project\Build\subproject.&#123;sa&#125;proj" /output=$self  &#40;TaskId:18&#41;
      The "Build" task is using "SmartAssembly.com" from "C:\Program Files\Red Gate\SmartAssembly 5\SmartAssembly.com". &#40;TaskId:18&#41;
      SmartAssembly v5.0.0.284 &#40;TaskId:18&#41;
      Copyright c Red Gate Software 2005-2010 &#40;TaskId:18&#41;
      Loading project X:\solutionfolder\project\Build\subproject.&#123;sa&#125;proj &#40;TaskId:18&#41;
        Output=X:\solutionfolder\project\subproject\obj\Release\subproject.dll &#40;TaskId:18&#41;
      Analyzing... &#40;TaskId:18&#41;
      Preparing... &#40;TaskId:18&#41;
      Creating Assembly... &#40;TaskId:18&#41;
      OK &#40;TaskId:18&#41;
    Done executing task "SmartAssembly.MSBuild.Tasks.Build". &#40;TaskId:18&#41;
    
  • Paul.MartinPaul.Martin Posts: 83 New member
    That is the annoying thing with MSBuild (and devenv.exe which is a wrapper around it), it redirects the console output to the logger and the default settings for the default logger are for a very quiet output.

    Glad you managed to find the problem.

    I'll log a feature request for the <Include ...> structure
  • Just one more note on the build output: setting it to minimal already produces useful output. Actually more than SA should but still useful.
    ------ Build started: Project: subproject, Configuration: Release Any CPU ------
      SmartAssembly v5.0.0.284
      Copyright c Red Gate Software 2005-2010
      Loading project X:\solutiondir\project\Build\GeneralAssemblies.&#123;sa&#125;proj
        Input=X:\solutiondir\project\subproject\obj\Release\subproject.dll
        Output=X:\solutiondir\project\subproject\obj\Release\subproject.dll
      Analyzing...
      Preparing...
      Creating Assembly...
      OK
      subproject -&gt; X:\solutiondir\project\Executables\Release\subproject.dll
    

    When set to minimal, this is the only output during build time.
Sign In or Register to comment.