Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The "ConvertMain" task failed unexpectedly #35

Closed
interrubke opened this issue Feb 28, 2020 · 4 comments
Closed

The "ConvertMain" task failed unexpectedly #35

interrubke opened this issue Feb 28, 2020 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@interrubke
Copy link

interrubke commented Feb 28, 2020

I have around 15 convert tasks in my project, like below.

 <Target Name="ConvertHubMessages" BeforeTargets="PrepareForBuild">
    <Message Text="Generating model :  HubMessages" Importance="high" />
    <ConvertMain WorkingDirectory="SignalRHubs/HubMessages/" ConvertDirectory="clientApp/server-models/hubMessages/" />
  </Target>
  <Target Name="ConvertEnums" BeforeTargets="PrepareForBuild">
    <Message Text="Generating model :  Enums" Importance="high" />
    <ConvertMain WorkingDirectory="../../src/SomeProject.BackOffice.Common/Enums/" ConvertDirectory="clientApp/server-models/enums/" />
  </Target>
  <Target Name="ConvertAccount" BeforeTargets="PrepareForBuild">
    <Message Text="Generating model :  Account" Importance="high" />
    <ConvertMain WorkingDirectory="Controllers/Api/Account/Models/" ConvertDirectory="clientApp/server-models/account/" />
  </Target>

When i build from scratch (no models generated) it works ok, but the second and other times the ConvertMain task crashes with the error:

  Error	MSB4018	The "ConvertMain" task failed unexpectedly.
System.UnauthorizedAccessException: Access to the path 'C:\projects\SomeProject\BackOffice\src\SomeProject.BackOffice.Web\clientApp\server-models\hubMessages' is denied.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileSystemEnumerableIterator`1.CommonInit()
   at System.IO.FileSystemEnumerableIterator`1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler`1 resultHandler, Boolean checkHost)
   at System.IO.Directory.GetDirectories(String path)
   at MTT.ConvertService.DeleteDirectory(String path, Int32 iteration)
   at MTT.ConvertService.GetConvertDirectory()
   at MTT.ConvertService.Execute()
   at MSBuildTasks.ConvertMain.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()	SomeProject.BackOffice.Web	C:\projects\SomeProject\BackOffice\src\Project.BackOffice.Web\SomeProject.BackOffice.Web.csproj	131	

It is not always the first one, more or less a random convert task. Is this related to the multiple tasks setup? Is there a way to prevent this?

@CodySchrank
Copy link
Owner

I've never tried to do multiple conversions like this. I've only ever done from one folder to another, so honestly I have no idea how MTT would handle this. I'll try making a test project to test this though and see if there is anything i can do.

@interrubke
Copy link
Author

Thanks.
We are using multiple converts for api models, enums (from another project), and so one.. these go into one server-models folder for the frontend.

@CodySchrank CodySchrank self-assigned this Jul 6, 2020
@CodySchrank CodySchrank added the bug Something isn't working label Jul 6, 2020
@CodySchrank
Copy link
Owner

CodySchrank commented Jul 6, 2020

MTT wasn't really designed to have multiple instances running, that is why you get access denied, another instance is already using those resources. I'm sure some kind of parallelization is possible, but I'm not really sure what that looks like with how it is setup now.

@nitro-codes
Copy link

nitro-codes commented Oct 7, 2020

@interrubke cascade the execution of the target tasks with either DependsOnTargets or AfterTargets like so...

  <Target Name="ConvertHubMessages" BeforeTargets="PrepareForBuild">
    ...
  </Target>
  <Target Name="ConvertEnums" BeforeTargets="PrepareForBuild" AfterTargets="ConvertHubMessages">
    ...
  </Target>
  <Target Name="ConvertAccount" BeforeTargets="PrepareForBuild" AfterTargets="ConvertEnums">
    ...
  </Target>

https://docs.microsoft.com/en-us/visualstudio/msbuild/target-build-order?view=vs-2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants