Creating build and publish script for .net Application using powershell - asp.net

I am new to power shell, I am trying to write a power shell script to build and publish the c#/.net application(Web). I have tried below code to generate build-
$projectFileAbsPath = .csproj path
$msbuild $projectFileAbsPath /t:rebuild /p:PlatformTarget=x86 /fl /p:outputpath=C:\test
by executing above line i am only getting dll of the project in destination folder. Supporting\Referenced dll's and related artifacts are missing.
Please help me understand where i am getting wrong and what additional things i need to do. Also, do i need any build configuration file .If yes, let me know if there is any sample posted on internet.

Related

dotnet build CS2012 cannot open dll for writing

I have a .Net Core 3.1 DLL project that all of a sudden didn't build anymore with the following error message:
CSC : error CS2012: Cannot open 'some.dll' for writing -- 'Access to the path 'some.dll' is denied.'
This project is not under any kind of source control. It's not on a build server (what most questions on Stack Overflow is about). It's a project on my local machine.
Now, to rule out Visual Studio I've tried to build it from the command line with dotnet. Same thing unfortunately. Things I've tried:
Close Visual Studio, delete obj folder + bin folder
Delete the entire project and made a new one with the same name
Removed project reference to other project (to rule out: dotnet core build in parallel or simultaneously)
The suggestions here error CS2012: Cannot open <executable path> access to <executable path denied>
This all didn't help. Then I had success for 1 build with:
Changing the target framework from 3.1 to 3.0
Changing the name of the project
This built the project once, because the filepath changes really, but then I got the same error the 2nd built.
Then I've had a few days success by:
Moving the entire solution to a new folder without the problematic project. Then adding a brand new project and adding the code to this complete new project.
But unfortunately after a few days I got the exact same problem. I have no idea what changed. It's always this project (which is a unittest project) and not the other project that it references (also a DLL project). I am out of ideas. Anybody have any suggestions for me to try?
Thanks in advance for helping.
Update
My project's name = "TheGenesysProject.Engine.Test" and it was indeed quarantined by my company's security software as Pavel said in the comments. So I changed it to "JustSomeLib" and the security software didn't quarantine it anymore! Why this is, I have no clue whatsoever...
Update 2
it must be something in the project itself and not the name of the dll. I restored JustSomeLib so it had the same NuGet packages (xunit + xunit.runner.visualstudio) plus .cs files (just 3 files with some unittests in them nothing fancy) as TheGenesysProject.Engine.Test and it all build and worked once! Then I coded some more stuff. Added an unittest to test my new code and... Bam! In quarantine again. What the heck?! I am just logging this for if people have the same problem as I do.
Update 3
Just to conclude this story. The folder with sourcecode is now excluded from the malware scan and the dll's are not put in quarantine. This solved this problem. Thank you Pavel.

"No files matched the search pattern" in tfs build

I want to build my project from TFS Azure(VSTS).
I have made one project which is under Asp.Net Core.
I have made Build definition with Asp.Net Core Template and given the path for restore like **\*.csproj but I am not sure about this path or not?
I have tried many options like **\admis.csproj and some others, but I have faced the same error as the one on the following image:
I am using Asp.Net Core 2.1. Any ideas?
Just check your Workspace mappings in Get sources step, make sure you have mapped the source directory which included the solution or project file *.csproj:
Please check!
1) Server path should be: $/YourDevOpsProjectName/YourBranchName/TheRestPathUntil .csproj file
As I see on your screenshot, your path should be $/0424Test/NetCoreApp/NetCoreApp (I'm assuming that your .csproj file is there).
2) I had the same problem, because when I tried to Queue build for my project, in Source version I set 1 and the process of the queue tried to take 1 source code version, that of course not exists.
If Source version's value is empty, it try to get the last version of your source code
3) Use **/*.csproj as "Path to project(s)" for every task in your Agent job.
Please check!
Server path should be: $/YourDevOpsProjectName/YourBranchName/TheRestPathUntil .csproj file

OpenCover in localhost with C# MVC 4 app

I just want to try OpenCover to get Coverage statistics from my app.
But I don't understand well how to use it. So here my questions?
Does the dll's have to be in the same directory? (my solutions have several projects)
Any example to get Coverage using OpenCover?
Is necessary to run the site in IIS Express or with ASP.NET development server is ok?
Thanks a lot!
I set up open cover as an external tool to make it easier on me.
Download the exe and drop it in a folder with as short a path as possible. then setup and external tool as follows:
Title : Open Cover {this is your choice}
Command: {your path to opencover}\OpenCover.Console.exe
Arguments: -register:user -target:"C:\Progra~1\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" -targetargs:"$(TargetName)$(TargetExt)" -output:coverage.xml -targetdir:"$(ProjectDir)\bin\debug"
Initial directory: $(TargetDir)
Set it to use output window and close on exit. You will need to adjust the test runner program to suit you, i use vs2012, if you do too, that will make it easier on you.
To use it, click your test project in your solution explorer, then click on the open cover external tool and it will generate you the coverage report. I use it with Report Generator.
Set it up as an external tool too:
Title: Report Generator
Command: {Your path to report generator}\ReportGenerator.exe
Arguments: $(TargetDir)coverage.xml $(TargetDir)\coverageResults
Again, set to close on exit and use output window.
after generating your coverage report, you can then use report generator to create a nice looking html version that you can click through and see the stats.
hth
The docs that are installed alongside OpenCover carry a lot of useful information about running OpenCover. You should have a copy of this file https://github.com/sawilde/opencover/blob/master/main/OpenCover.Documentation/Usage.pdf in you download package (MSI/ZIP/NUGET)
The DLLs do not need to all be in the same directory but you will normally find that this happens due to the build process. Any assemblies that you want to gather coverage from will require that the PDBs for those assemblies to be in the same directory as the assembly or in the folder referenced by targetdir switch.
Yes you can use it to run iisexpress or the ASP.NET development server use the target switch.

Build Process in TFS 2010

I have read articles on build automation and it looks simple, but I am really not sure about parameterized build. I believe, there must be a xml file for that.
When we say build is automated, I believe it means our code/binaries sit in test environemnt. And all application related settings will also configured just by simple clicks of build, and push.
What are the required tools? What is MSBuild ?
Please put some light on it.
MSBuild is and exe that you run with command line tools and pass to it the project file (.csproj) which is an XML file as you said and it has all the instructions needed as you configured.
I created a series of videos that describe how to create simple MSBuild tasks and how to organize tasks and so on, for more info click on the following link:
MSBuild Tutorial
MSBuild is exe
When you run MSBuild from Command line
You will need to unload the projct so you can edit the (.csproj) or project file
The (.csproj) or project file
You are asking about build automation, and by your tags you menation TFS 2010 if so then you only need a cursory understanding of msbuild to get started. It is what eventually calls the compiler, but in all hoensty you need the step above it which are the build templates and defintions, along with how to set up agents and controller.
Here is a good overview document by Martin Woodward, this should give you enough to figure things out, or ask more specific questions

create setup for an existent exe file

I want to create a setup for an existent .exe file. This file needs some .ocx and .dll files to run correctly. So this mentioned setup should paste these all files in a specified path and then run the .exe file.
I have tried with installshield 2010 basic and InstallScript projects but i could not create some of dialogs in the format that i wanted.
Is there any way to create this setup? Or any one may help me to work with installshield?
You might find working with another setup program easier, try the NSIS (Nullsoft Scriptable Install System). It has a RegDLL function:
RegDLL "$WINDIR\OCX\vbalGrid6.ocx"
if you need that also.

Resources