none
MSBuildProcess keeps reappearing RRS feed

  • Question

  • I am quite new to the MSBuild Process and I am stuck on this error for 2 days now. I have a consoletool, which gets called during a build process and is packed into a nuget, so it can easiliy be used by other projects. The consoletool analyzes used packages in the project where the nuget is included and creates a folder where the console tool places its output. This all works as expected, but the msbuild process never seems to really stop or at least reappears after the execution is finished. I can see, that the folder which is created during the build process just keeps getting recreated again and again. In the windows explorer I can see the processes disappearing just to reappear again. 

    Here are all the files, which are involved in my msbuildprocess:

    myapp.target

        <Project>
          <Import Project="$(MSBuildThisFileDirectory)/../../tools/mytargets.targets" />
        </Project>

    mytargets.targets

     <Project>
          <Target Name="check" AfterTargets="CoreCompile">
            
            <PropertyGroup>
              <Output>files</Output>
              <Directory>$(MSBuildProjectDirectory)$(Output)</Directory>
              <Exe>dotnet $(MSBuildThisFileDirectory)mytool.dll</Exe>
              <Call>$(Exe) $(MSBuildProjectFullPath) $(Directory)</Call>
            </PropertyGroup>
        
            <MakeDir Directories="$(Directory)"/>
            <Exec Command="$(Call)" />
            
          </Target> 
        </Project>


    myapp.nuspec

    <package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
          <metadata>
            <id>testtool</id>
            <version>1.0.0</version>
            <authors>author</authors>
            <description>
              bla
            </description>
          </metadata>
          <files>
            <file src="lib\netstandard1.0\_._"                                target="/lib/netstandard1.0/" />
            <file src="build\netstandard1.0\myapp.targets"                  target="/build/netstandard1.0/myapp.targets" />
            <file src="tools\mytargets.targets"                               target="/tools/" />
            <file src="$publishdir$\netcoreapp2.1\**\*"                       target="/tools/netcoreapp2.1/" />
          </files>
    </package>


    myapp.csproj

     <Project Sdk="Microsoft.NET.Sdk">
          <PropertyGroup>
            <OutputType>Exe</OutputType>
            <AssemblyName>assemblytest</AssemblyName>
            <TargetFramework>netcoreapp2.1</TargetFramework>
          </PropertyGroup>
        
          <!-- Pack settings -->
          <PropertyGroup>
            <NoPackageAnalysis>true</NoPackageAnalysis>
            <NuspecFile>myapp.nuspec</NuspecFile>
            <IntermediatePackDir>$(MSBuildProjectDirectory)/bin/$(Configuration)/publish/</IntermediatePackDir>
            <PublishDir>$(IntermediatePackDir)$(TargetFramework)/</PublishDir>
            <NuspecProperties>publishDir=$([MSBuild]::NormalizeDirectory($(IntermediatePackDir)))</NuspecProperties>
          </PropertyGroup>
        
          <!-- Executes /t:Publish for all target frameworks before packing-->
          <Target Name="PublishAll" BeforeTargets="GenerateNuspec">
            <ItemGroup>
              <_TargetFramework Include="$(TargetFramework)" />
            </ItemGroup>
            <MSBuild Projects="$(MSBuildProjectFullPath)" Targets="Publish" Properties="TargetFramework=%(_TargetFramework.Identity)" />
          </Target>
        
          <ItemGroup>
            <Folder Include="src\" />
            <Folder Include="tools\netcoreapp2.1\" />
          </ItemGroup>
        
          <ItemGroup>
            <PackageReference Include="Microsoft.Build.Framework" Version="16.0.461" />
            <PackageReference Include="Microsoft.Build.Utilities.Core" Version="16.0.461" />
          </ItemGroup>
        
        </Project>

    And this is the structure of the project, which produces the nuget package

     myapp
           build
             netstandard1.0
                myapp.targets
           lib
             netstandard1.0
                _._
           src
             program.cs
           tools
             mytargets.targets
             netcoreapp2.1
           myapp.nuspec

    The nuget is referenced as usual. I don't really know what to try anymore or how I could further analyze it. I'd be really thankful for some tips :)



    Tuesday, October 1, 2019 8:35 AM

All replies

  • Hi msbuildamateur,

    Welcome to MSDN forum.

    Base on your description, we suggest you could run the below command using cmd to kill the msbuild process.

    taskkill /im msbuild.exe /f /t

    BTW, if you build it in VS IDE, please go to Tools/Options/build and run, then set "..build output.. " to diagnostic, then your could check the build details in output window. And if possible, could you please post the log or share it as file here, it will help us to analysis it better.

    Any feedback will be expected.

    Best Regards,

    Dylan



    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

    Wednesday, October 2, 2019 5:07 AM
  • taskkill /im msbuild.exe /f /t

    the command closes the task, but the investegated task just restarts right after that. 

    Since i'm not verfied, I can't post files or links yet. Is there another option?




    Wednesday, October 2, 2019 10:18 AM
  • Hi msbuildamateur,

    Thank you for feedback.

    We recommend you could run msbuild process using cmd, then check if this issue persists:

    BTW, not sure if it is also related to your console tool, please check if there is a loop that keeps calling msbuild tool.

    Any feedback will be expected.

    Best Regards,

    Dylan


    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

    Thursday, October 3, 2019 3:48 AM

  • I completly forgot about the console tool, which executes 

    msbuild", $"\"{projectPath}\"", "/t:GenerateRestoreGraphFile", $"/p:RestoreGraphOutputPath={dgOutput}

    Edit:

    I really thought this has to be it. But after deleting this part of the code of the exe tool, the execution of the process is still infinite. The process just keeps running. Is there a possiblity, that

    dotnet C:\Users\MATI\source\repos\LicenseResolver\LicenseResolver\bin\Debug\netcoreapp2.1\mytool.dll
    causes the infinite loop since dotnet builds the dll?


    Monday, October 7, 2019 6:53 AM
  • Hi msbuilddamateur,

    Thank you for feedback,

    As far as I know, the msbuild and dotnet could not run automatically in the background. Could you share a simple sample about console tool? which would help us reproduce this issue and analysis this issue better.

    Look forward to your reply.

    Best Regards,

    Dylan


    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

    Tuesday, October 8, 2019 9:04 AM
  • Hi Dylan,

    I added the 

    <CallTarget Targets="GenerateRestoreGraphFile" />

    to my mytargets.targets file, while commenting out the call for the console tool.

    The result stays the same, the msbuild process won't stop.

    As soon as I delete the graphfile (created by the target GenerateRestoreGraphFile), it is recreated, which means the process is running the whole time, though I don't get any output besides the files. 

    All my Messages only give output on the first build.

    I use VS2019 if it makes any difference. 

    Wednesday, October 9, 2019 6:18 AM
  • Hi msbuilddamateur,

    Sorry for delay in reply.

    As normal, the target is just call once, but if the properties would be changed, it would keep going to execute. From original csproj file, please have a try to modify the targetFramework to a unique parameter like:

    <MSBuild Projects="$(MSBuildProjectFullPath)" Targets="Publish" Properties="TargetFramework=netcoreapp2.1" />

    Sorry for missing this point, and hope it could help you.

    Best Regards,

    Dylan


    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, October 11, 2019 6:37 AM