Is it worth learning to use MSBuild?

前端 未结 10 2078
清酒与你
清酒与你 2021-02-18 15:20

I simply wondered whether people thought it was worth learning to use the MSBuild syntax in order to customise the build process for a .net project, or whether it is really not

相关标签:
10条回答
  • 2021-02-18 15:45

    Building from the command line with MSBuild is relatively easy to learn. Start by opening a Visual Studio Command Prompt, and running msbuild /?. Just read through the help once and then decide later if you want to learn more details.

    Writing project files is a bit more complicated. Most people don't need to learn it, because you can do most things in Visual Studio. However, it's also quite powerful for certain problems.

    I have in the past used MSBuild as scripting language, combined with lots of custom tasks. MSBuild has fantastic logging support + built-in dependency management. However, it's not an easy language to learn. PowerShell is a much better choice.

    0 讨论(0)
  • 2021-02-18 15:50

    MSBuild is absolutely worth the time to learn. After the initial learning curve (which might be very steep actually) it becomes fairly easy to do the most common build automation steps.

    • building assemblies in RELEASE mode
    • signing assemblies with strong name
    • running unit tests
    • modifying xml files / Web.config-s on the fly
    • modifying the version number of the assemblies
    • validating FxCop / StyleCop etc...
    • automated deployment - create SQL databases, IIS websites, windows services etc...
    0 讨论(0)
  • 2021-02-18 15:55

    @kronoz
    I would say YES.
    The neat thing about MSBuild is that if you modify your csproj files to include custom build steps then those steps will happen from within VS or from MSBuild. Also if you ever have a build server you will not need to install full VS, only the SDK to build your projects.

    0 讨论(0)
  • 2021-02-18 15:56

    It sounds like you are a single developer working on your own site. If this is the case, it's not necessary at all, but it is still a good idea for you to learn as a part of your professional experience.

    Automated building of projects becomes more necessary as the number of developers working on a project increase. It is very easy for two developers to write incompatible code which will break when it is combined (imagine I'm calling a function foo(int x), and you change the signature to be foo(int x, int y): when we combine our code bases, the code will break.

    These types of errors increase in complexity and hassle with the amount of time between integration builds. By setting up nightly builds, or even builds that occur every check-in, these problems are greatly reduced. This practice is pretty much industry standard across projects with multiple developers.

    So now, to answer your question: this is a skill that will span across projects and companies. You should learn it to broaden your knowledge and skills as a developer, and to add an important line on your resume.

    0 讨论(0)
  • 2021-02-18 15:57

    MSBuild is incredibly simple to use, you can use VS to manage the projects and solution files and just pass the SLN to MSBuild.

    0 讨论(0)
  • 2021-02-18 15:57

    If you develop in .net workshop, It does worth learning.
    I have integrated our build process with Jenkins - originally Hudson. As it mentioned above, MSbuild has steep learning curve.However once you grasp the fundamentals, you can start customizing the build. my impression so far - could be naive, bulk of the script is consisted of

    <PropertyGroup>
       <PropertyKey>value</PropertyKey>
    </PropertyGroup>
    <ItemGroup>
       <ItemListKey>List values<ItemListKey>
    </ItemGroup>
    <Task Source="" Target="" />
    
        Besides using for build, I successfully used MSBuild to create a module that manages
        configuration files such as web.config and foo.exe.config files. 
        it is a hybrid module that consists of .net console app, MSBuild script and batch file.
        what this module does is that during a project upgrade, it will create a XML transform       
        template with connection strings, endpoints and appSettings from old configuration
        files. 
        after the project has been upgraded, the module will transform newly deployed  
        configuration
        files without affecting any new entries. if you have dozens of configuration files this  
        is very effective. 
    
    0 讨论(0)
提交回复
热议问题