ASP.NET Core Change Build directory - build

Does anyone know how to change the Build directory of an ASP.NET Core project? In the project settings under build, the output path is readonly.

You can define pre/post script commands in your project.json in the scripts section. Even execute multiple commands, when you turn the postcompile from string to an array ["command1", "command2", "command3"]
Other workaround is-
Open your ASP.NET core project .xproj file in Notepad and change OutputPath
from
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
to
<OutputPath Condition="'$(OutputPath)'=='' ">E:\SanketTest</OutputPath>
Once done, reload your project and it will automatically build in specified location.
See if this helps.

Edit the .csproj file manually.
Set the Outputpath as desired:
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<OutputPath Condition="'$(OutputPath)'=='' ">..\bin\Release\</OutputPath>
</PropertyGroup>
This will still generate subfolders for the framework version and the runtime identifier. To remove those add this to your project file:
<PropertyGroup>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
</PropertyGroup>

ASP.NET Core projects are built using the .NET Core CLI. The output can be controlled by adding options the command-line call do "dotnet build".
Example:
dotnet build --output bin/whatever/ --framework netcoreapp1.0
See dotnet build --help for all available parameters.

Related

Deploy a custom built project with QtCreator

I am using a custom build system (not CMake or qmake) with QtCreator 4.6.0 IDE on Linux, though I have both of these plugins installed.
My project is cross-compiled for an embedded Linux device, which I have set up the kit for. It builds fine, but the trouble is in the deployment step, where the custom build system does not tell it the executable file, so it does not know which files to deploy to the device. I have been referring to this page:
http://doc.qt.io/qtcreator/creator-deployment-embedded-linux.html
In my Run Settings page, I have the Deployment section to "Upload files via SFTP", but the "Files to deploy" list is empty (see the first screenshot in the above link). When I attempt to deploy/run, it confirms no files were deployed, as it outputs:
No deployment action necessary. Skipping.
Deploy step finished.
The documentation link first says to "Edit the qmake INSTALLS variable in the project .pro file to add the missing files.", however, my project has no .pro file at all. I created one for fun, and QtCreator has no idea it exists to be able to look at the INSTALLS line anyway, so that doesn't work.
In the "Deploying CMake Projects to Embedded Linux Devices" section at the bottom, it then says "You must specify all other files in the QtCreatorDeployment.txt file that you create and place in either the root directory of the CMake project or the build directory of the active build configuration." So I created such a file in the main project directory, as well as the build directory:
/home/root
build/test:.
The file makes no difference to the "Files to deploy" list, even after restarting. It seems to suggest this method is for CMake anyway. However, I have not even explicitly turned off the CMake building in the Build&Run > Kits, so I would not even know how to start making it build with CMake (and there is no insight from the documentation page: https://doc.qt.io/qtcreator/creator-project-cmake.html). The one thing I did change on the Build Settings page was in the "Build Steps" to do "Custom Process Step" instead of the usual Make step.
How do I add files to the "Files to deploy" list?
QtCreator 4.9 now supports specifying the QtCreatorDeployment.txt file for generic (non-CMake) projects to achieve this.
https://doc.qt.io/qtcreator/creator-deployment-embedded-linux.html#deploying-cmake-projects-to-embedded-linux-devices
https://blog.qt.io/blog/2019/02/21/qt-creator-4-9-beta-released/

Dotnet command failed with non-zero exit code on the following projects

I have set up a build definition on VSTS. It builds fine on my local machine. But I get the following error when I start the build process
[error]Dotnet command failed with non-zero exit code on the following projects : D:\a\1\s\My.Project\My.Project.csproj
Check the project name in the error carefully. Chances are its not actually in your solution .sln ... and wouldn't build if it were. By default, VSTS will try to build all .csproj files regardless whether they are in your solution or not. Remove all .csproj files for projects you don't want to be built.
In my case. I deleted the \My.Project directory (which contained the .csproj file) and the build suceeded.
edit your.csproj and add MvcRazorCompileOnPublish as false
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<PreserveCompilationContext>true</PreserveCompilationContext>
<MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish>
</PropertyGroup>
views will be included in publish without the VSTS build failure.
In my case, my project had the line <IsPackable>false</IsPackable> in the csproj file, which caused the Pipeline job to fail in DevOps when it tried to create a package.
I faced similar issue with my automation code's Build pipeline with CI. I was using ".Net Core" task for test execution.
Solution:
I switched my "test" execution task from .Net Core to "Visual Studio test".
In VSTest task under "Test files" i specified exact project name which contains Test Cases. Instead of main solution.dll. As shown in image.

XAML build not able to run Unit Test

I am trying to run Nunit Test using Visual Studio test Runner from XAML build in TFS,but i am getting error saying
TF900547: The directory containing the assemblies for the Visual Studio Test Runner is not valid ''.
Based on your history, I assume you are using VSTS, you can refer to these steps to run Nunit test:
Create a unit test project via VS
Install NUnit and NUnit3TestAdapter packages
Add solution to source control (if the package files not added to the source control, you can refer to the steps below)
Open Source Control Explorer in VS
Add a new folder (e.g. Tools) and add Nuget.exe to the source control
Add bat file to your test project (For example: Tools\nuget35.exe restore NUTest2\NUTest2.sln)
Open XAML build definition and map Tools source folder to agent
Select Process section
Choose TfvcTemplate.12.xaml build template
In the Advance section of Build, specify Pre-build script path with previous bat file.

TFS Build Server with project with "custom build tool"

I'm setting up an TFS 2010 Build server.
But I currently have the problem that projects with an "custom build tool" won't build because of "no access".
The projects are C++.
The custom build tool is "Pro*C". Basically, you have an *.pc file, and it generates an *.cpp file.
But on the build server, the directory/files are readonly. So it will crash on "no access".
I have tried to remove the *.cpp file from TFS. So that the generated file does not exists. But apparently the folder is also readonly and won't allow to create a new file.
Does anyone has a workaround for this?
I would suggest one of these options:
Don't put the .cpp files in source control if they are generated by the build process
Change the settings for Pro*C to write its output files to a writable intermediate folder
Add a build step that copies the problem files to an intermediate location for processing
Add a build step that forces the file access on those files to be readable for processing
If you only need to build those files occasionally, then build them manually with Pro*C on your developer machine and check in the results, so you don't waste time unnecessarily rebuilding unchanging files with every desktop or build-server build.
There is a project called MSBuild Community Tasks, which can be downloaded from http://msbuildtasks.tigris.org/. I used it for my own for an automated tfs-build.
It provides you with several extensions for your msbuild-project. One of this is the so called Attrib task, which gives you the opportunity to change file (and probably folder) attributes out of you project. It's not listed in the table on the website, but its documented in their documentation. As a sample from their documentation, you can add the following line to a target of your choice:
<Attrib Files="Test\version.txt" ReadOnly="true" Hidden="true" System="true"/>
I think this will also work for an item-group as follows
<Attrib Files="#(AllYourFiles)" ReadOnly="true" Hidden="true" System="true"/>
If you want to use it, don't forget to install it on the build server. ;)

DeploymentProvider in manifest of ClickOnce depends on <Import Project=.. in project file

When I publish my project in VS2010 for ClickOnce a strange value for <deploymentProvider codebase="file://oldserver/.../....application" /> was present in my manifest file. The name oldserver name was wrong, it had to be replaced.
I didn't have a clue where the name oldserver came from?
In the project file I had
<InstallUrl>\\newserver\...\</InstallUrl>
but when opened, in the project properties in VS2010 oldserver was again displayed as publish folder location.
SOLUTION: In a hidden file called buildconfig.targets this was configured.
This file was referenced in the .proj file:
<Import Project="buildconfig.targets" />
In this file you need
<UpdateUrl>\\newserver\...\</UpdateUrl>
as well!
If you're publishing from Visual Studio, make sure you set the Install Url.
It's in the publish settings (in project settings for the project you are publishing) underneath the install url.
If you're publishing from MSBuild, then you need to set the UpdateUrl property (/p:UpdateUrl=youraddress for example).
When looking at your project in Visual Studio. select Build and then Configuration Manager. Check the information in your build configurations for Debug and Release and make sure they are correct. This is a total guess, but I could see something being set up in there.