0
votes

I am working on Azure DevOps CI CD Pipelines. The project's Backend is Dotnet Core, Frontend is Angular 8 and for Database, we used Entity Framework code-first approach. I was able to add Front and back end in pipelines. Now I am stuck with database deployment. since I was also unable to find any dedicated article.

The project is consists of Multi Context and Multi-Project. Reference folder structure

At local we usually run this command to generate migration and it works fine.

Add-Migration -Context ABCCompanyContext AddCompanyTable

Now, in Pipeline i have added the following command which I get from stackoverflow it self. but it didn't work. But from the error. it seems like I am really close

Pipeline Command

dotnet tool install --global dotnet-ef dotnet ef migrations script -i -o $(Build.ArtifactStagingDirectory)\Migrations\migrate.sql --project **/ABC.Company.Data.csproj --startup-project **/ABC.Company.Api.csproj -i -o $(Build.ArtifactStagingDirectory)\Migrations\migrate.sql

Error Log

2020-12-24T06:49:27.0265041Z ========================== Starting Command Output =========================== 2020-12-24T06:49:27.0688206Z ##[command]"C:\windows\system32\cmd.exe" /D /E:ON /V:OFF /S /C "CALL "D:\a_temp\f3a33029-4f61-404f-9b64-c73c5296123a.cmd"" 2020-12-24T06:49:32.9358440Z You can invoke the tool using the following command: dotnet-ef 2020-12-24T06:49:32.9359182Z Tool 'dotnet-ef' (version '5.0.1') was successfully installed. 2020-12-24T06:49:38.4701578Z System.IO.IOException: The filename, directory name, or volume label syntax is incorrect. : 'D:\a\1\s*\obj' 2020-12-24T06:49:38.4702878Z at System.IO.FileSystem.CreateDirectory(String fullPath, Byte[] securityDescriptor) 2020-12-24T06:49:38.4703503Z at System.IO.Directory.CreateDirectory(String path) 2020-12-24T06:49:38.4704199Z at Microsoft.EntityFrameworkCore.Tools.Project.FromFile(String file, String buildExtensionsDir, String framework, String configuration, String runtime) 2020-12-24T06:49:38.4705029Z at Microsoft.EntityFrameworkCore.Tools.RootCommand.Execute(String[] _) 2020-12-24T06:49:38.4705729Z at Microsoft.EntityFrameworkCore.Tools.Commands.CommandBase.<>c__DisplayClass0_0.b__0(String[] args) 2020-12-24T06:49:38.4706399Z at Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(String[] args) 2020-12-24T06:49:38.4707003Z at Microsoft.EntityFrameworkCore.Tools.Program.Main(String[] args) 2020-12-24T06:49:38.4707626Z The filename, directory name, or volume label syntax is incorrect. : 'D:\a\1\s*\obj' 2020-12-24T06:49:38.6646502Z ##[error]Cmd.exe exited with code '1'. 2020-12-24T06:49:38.7627325Z ##[section]Finishing: Build EfCore Migrations

1
Hi @Harshdeep Singh, How are things going? Have you tried the suggestion in my answer? Is it helpful to you? Please try it. Any progress, feel free to tell me.Bright Ran-MSFT

1 Answers

0
votes

The error message,

System.IO.IOException: The filename, directory name, or volume label syntax is incorrect. : 'D:\a\1\s\*\obj'

The path string contains the character '*'. Normally this character is not available in file name and folder name.

As the introduction from the docs about .NET Core CLI, the values of the options '--project' and '--startup-project' are the relative paths to the project folders.

According to my test, in the 'dotnet ef' command, it seems does not support wildcard patterns.

  • When I use wildcard patterns to set the path values, it always return the same error message.

System.IO.IOException: The filename, directory name, or volume label syntax is incorrect. : 'D:\a\1\s\**\obj'

  • However, when I directly provide the complete relative paths instead of using wildcard patterns, the error disappears.

So, I recommend you directly use the complete relative paths to the project folders.