Warning MSB3245: Could not resolve this reference. Could not locate the assembly “HelloWorld.Core”. Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
Error CS0234: The type or namespace name ‘Core’ does not exist in the namespace ‘Document360’ (are you missing an assembly reference?)
Are you seeing your Azure Pipelines build failing with similar error/warning message? It’s very likely that it’s a missing project dependency issue. It’s a usual case when you have a solution inside which you have multiple project and have added project-A as a dependency in project-B under the same solution.
How to fix Error CS0234: The type or namespace name ‘XXXX.Core’ does not exist in the namespace ‘XXXX’?
Check if you have added the project as dependency. It’s likely that you may have added the reference to the project’s DLL instead of the Project itself inside the solution.
While adding the reference to another project – always add the reference to the Project, and not the Project’s DLL by browsing for it.
While adding the reference you can find all the project for the current solution under “Projects” tab. Select the project that you want to refer. This way it will always build the referred Project first and then the current one (to resolve the dependency).
There’s another way of doing this. You can right click on the solution and select “Project Dependencies”. This window allows you to select the project and mark the projects it is dependent on.
Learn how to run console apps on Azure DevOps without hosting!
I came across multiple similar questions on StackOverflow for running a Console Application on Microsoft Azure. Answers mostly suggesting running the console app on WebJobs. Here I’m sharing another way of running console apps on Microsoft Azure DevOps, with Azure Pipelines.
[Azure]: Run your console app on Azure Pipelines
If you have a subscription to Azure DevOps, you will be able to run your console app. Upload your console app and create a pipeline to run a script. Add the command and necessary arguments if any and run the pipeline.
Note: At the time of writing this post I'm not sure of any downside of this approach, will update here if I find one.
What did I do?
In Azure DevOps, under one of demo Organizations I created a test project (“TestProject”), and initialized the empty repository with README.md file.
Created a new C# Console App Project in Visual Studio 2019. “HelloWorld-Console”.
Published the executable. While publishing, I changed the deployment mode to “Self-contained” and enabled “Produce single file” option. It produced 2 files in the publish folder:
since .pdb file file contains debugging info, I had my concerns only with the executable (.exe) file.
I tried uploading the file in the Azure DevOps repository directly from the browser but the browser has a limitation of 20 MB max per file. So I chose to upload it using the git tools.
I cloned the repository on my machine, copied the executable (.exe) in the repository from the publish folder, staged the changes, committed and pushed it to remote repository.
Finally, I setup a pipeline with a “Command Line Script” task to run the executable. Since it’s a Windows executable file, I set the Agent specification to “Windows-2019”.
In the “Script” block I just entered the file name of console app as it didn’t require any additional parameter to run.
The pipeline ran just fine and I could see the output from the console app in the logs: ?
In the pipeline, I extended the command to save the console app output to a text file. I added one more task to publish the output file in artifacts directory. I kept the artifact’s name as “pipeline-run-$(Build.BuildNumber)” in order to have different folder for every run, containing the output text file.
Now for every run of the pipeline, I could see an artifact produced, containing the output text file.
So, with that I’m wrapping this post but you can always extend the pipeline with tasks to share the console app’s output to email, or other channels. This way you can run your console apps without an App Service/WebJob/Azure Functions. The Azure DevOps platform will run the console app for you for free I guess, until they start charging. ?
Further, you can extend the pipeline with scheduled trigger to run it on scheduled time as well.
? Did I miss anything or you have any feedback? Please help me fix it by dropping a line at firstname.lastname@example.org, thanks!