none
Local developer publishing

    Question

  • We are a small/mid sized development team and are not ready to leverage VSTS online to automatically perform builds/publish.

    Currently (I know this is poor practice) our developers (we use Github) ensure they have the latest relevant commits on whatever branch and then right-click "publish" in Visual Studio, publishing to the local file system.

    The developer then copies the publish folder's contents to some well known location in preparation for eventual testing, QA etc.

    It would be a great help if we could have the .pubxml NOT be user specific (i.e. place that in source control) and it would be great too if we could edit the .pubxml and add some option to force clean before publishing, ensuring that every assembly in a solution is freshly created and has a current date-time modified.

    Can anyone suggest how to do this? Or can anyone suggest some steps we can take to improve how we do this without having to move to a fully automatic publish/deploy process?

    I want to do the latter but right now we are so limited in time that such a step is beyond our resources and requires we liaise with other departments and establish new ways of working and so on, so this is something we want to work towards gradually rather than in some huge leap.

    Many thanks,


    Thursday, December 21, 2017 10:43 PM

All replies

  • Hi Korporal Kernel,

    >>> if we could edit the .pubxml and add some option to force clean before publishing, ensuring that every assembly in a solution is freshly created and has a current date-time modified.

    Do you mean you want to clean the publish folder before publishing? If yes, you can use a clean task to clean that folder in the project file after build. If I misunderstand you, could you please use a instance to describe what you want? And why you want to do this.


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, December 22, 2017 3:03 AM
  • Hi Korporal Kernel,

    >>> if we could edit the .pubxml and add some option to force clean before publishing, ensuring that every assembly in a solution is freshly created and has a current date-time modified.

    Do you mean you want to clean the publish folder before publishing? If yes, you can use a clean task to clean that folder in the project file after build. If I misunderstand you, could you please use a instance to describe what you want? And why you want to do this.


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Not quite - I want to force the publish step to do a clean/rebuild (of each project's output folder) so that ALL projects in the solution get forcibly rebuilt.

    We use a simple (but very helpful) tool named NetRevisionTool (open source on Github) this tool is used by adding a pre-build and post-build event and an updated AssemblyInformationVersion attribute for the project.

    This causes the Git commit ID to be automatically inserted into the attribute so it becomes part of the generated assembly's metadata.

    But if a developer does a pull and gets the latest commit (often a merge commit from a pull request) then often there's no change to source files and so the projects won't get rebuilt ordinarily.

    I want to ensure that when we publish the actual latest commit ID for the developers current branch is picked up and the only way to do this is to do a clean/rebuild before we do a publish - but humans forget sometimes.

    So is there any form of XML node I can insert into the .pubxml that forces a clean (not of the publish folder but the project's output folder) so that every project is garuanteed to get rebuilt simply when we click "publish"?

    Thx

    One way we use this if you're curious is that we have a simple support library that gets the details of the Git metadata at runtime. We can then include this in log messages and also many web apps/services have a way to expose this too (e.g. the home page of many apps have a hidden HTML string with all this metadata in it, just doing a view-source lets developers see commit ID, machine name the app's running on, build date-time, who built it, what repo and branch it was built on, name of developer who built it, name of machine it was built on etc - hugely useful to us in a support role).




    Friday, December 22, 2017 2:34 PM
  • @Korporal Kernel, thanks for your detailed reply. I understand that you want to forces a clean for the output folder so that each submission has its own github submit ID for current branch.

    To accomplish this, you can add a InitialTargets into your project file to clean the output folder before build start, for example:

    Add InitialTargets="Clean" in the second line in the project file .csproj:

    <Project InitialTargets="Clean" ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

    Then add a target Clean in the project file:

      <Target Name="Clean">
        <Message Text="Clean the output folder!" ></Message>
        <RemoveDir Directories="$(ProjectDir)$(OutDir)"></RemoveDir>
      </Target>

    When we publish the project, this target will clean the output folder, then VS/MSBuild will rebuild the project:

    Hope this helps.


    MSDN Community Support Please remember to click Mark as Answer. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Monday, December 25, 2017 6:19 AM
  • @Korporal Kernel, thanks for your detailed reply. I understand that you want to forces a clean for the output folder so that each submission has its own github submit ID for current branch.

    To accomplish this, you can add a InitialTargets into your project file to clean the output folder before build start, for example:

    Add InitialTargets="Clean" in the second line in the project file .csproj:

    <Project InitialTargets="Clean" ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

    Then add a target Clean in the project file:

      <Target Name="Clean">
        <Message Text="Clean the output folder!" ></Message>
        <RemoveDir Directories="$(ProjectDir)$(OutDir)"></RemoveDir>
      </Target>

    When we publish the project, this target will clean the output folder, then VS/MSBuild will rebuild the project:

    Hope this helps.


    MSDN Community Support Please remember to click Mark as Answer. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Thanks.

    This almost worked, in the project that I added it to though it fails:

    1>------ Publish started: Project: EnrollmentManagement, Configuration: Debug Any CPU ------
    1>Connecting to C:\release\Enrollment...
    1>Copying all files to temporary location below for package/publish:
    1>obj\Debug\Package\PackageTmp.
    1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.Web.Publishing.targets(3003,5): Error : Copying file bin\EnrollmentManagement.dll to obj\Debug\Package\PackageTmp\bin\EnrollmentManagement.dll failed. Could not find file 'bin\EnrollmentManagement.dll'.
    1>
    ========== Build: 0 succeeded, 0 failed, 2 up-to-date, 0 skipped ==========
    ========== Publish: 0 succeeded, 1 failed, 0 skipped ==========
    

    Not really sure how to fix this, here's the Project line after my edits:

    <Project ToolsVersion="14.0"  InitialTargets="Clean" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    

    Any help appreciated !

    Tuesday, January 2, 2018 3:26 PM
  • @Korporal Kernel, 

    According to the error log, 

    Copying file bin\EnrollmentManagement.dll to obj\Debug\Package\PackageTmp\bin\EnrollmentManagement.dll failed. Could not find file 'bin\EnrollmentManagement.dll'

    That seems that EnrollmentManagement.dll is missing in the bin folder, so make sure this dll file is generated after build. Please check the bin folder if that dll file exists or not. You can change the log to Detailed to check the log on the output window. 

    Note: please update your Visual Studio to the latest version, there is a issue on the 15.3, which VS/MSBuild will delete the dll file in the bin folder after publish complete.


    MSDN Community Support Please remember to click &quot;Mark as Answer&quot; the responses that resolved your issue, and to click &quot;Unmark as Answer&quot; if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, January 3, 2018 10:46 AM