I have a test-project which performs WebDriverTests.
At this moment I have the following in my code:
private readonly string url = #"http://localhost:3000/#/search/persons";
My application (including the webdrivertests) is deployed using TeamCity (installed on PC-A) and deploys the application to PC-B.
When the deployment is done, I want to run my webdrivertests on PC-B as part of the TeamCity-deployment. But with the above mentionned line this doesn't work since the application isn't deployed on the server where my TeamCity is running.
Is there a way to do this using an app.config?
Or is there another way?
Absolutely. Richard Bradshaw (#FriendlyTester on Twitter) has a great approach to handle this. I use the same approach, Richard just has an existing great blogpost I can point you to.
Related
I built this creating-web-apis-using-asp-net-and-mysql-in-5-minutes
The api runs fine on my local machine windows 10 with visual studio 2017 enterprise. I have a centos box running on VMware in another location this is where my MySQL database is. When I run the api on my local machine I use a connection string with a FQDN and the api runs fine. FYI the api also has a method without database access that basically sends back a json string ["value1","value2"] both this and the one that gets a user from MySQL work fine on local machine.
Next I set it up as a service on the Centos box and set up apache to proxy to the kestrel web server at localhost:5000 using these instructions Host ASP.NET Core on Linux with Apache. my Apache virtual host config is the same as the one in the example except no server alias and no logging. I didn't want a server alias and the logging commands stopped the service from starting. I also needed to upgrade apache from the Centos's repo apache 2.4.6 to Apache 2.4.36 I think.
I did this using a third party repo because RequestHeader set "X-Forward-Proto" expr=%{REQUEST SCHEME} needed Apache 2.4.10 or above.
It should be stated that I used my own database and not the example one it is basic just returns user info like uname etc.
If I run http://MyFQDN/api/values I get the desired response.
If run http://MyFQDN/api/users/1 which when run on my local machine while debugging returns a json string with the correct information using a MySQL connection string with a FQDN and not localhost:3306 or 127.0.0.1:3306 as the server in the connection string. When I try it on the Linux box no go.
Instead I get the infamous http 500 error which I believe means that program is not running correctly the only difference here is the MySQL connection string or there is something else.
in the demo it says
Some values (for example, SQL connection strings) must be escaped for the configuration providers to read the environment variables. Use the following command to generate a properly escaped value for use in the configuration file
However I have tried several times using the example
systemd-escape … see demo for exact syntax as it doesn't escape well here funny.
I believe if I had a properly escaped MySQL connection string that would work on kestrel in the Centos box it might work.
This is in appsettings.production.json
"ConnectionStrings": {
"DevDatabase": "Server=127.0.0.1;Port=3306;Database=nameOfDatabase;Uid=svcuser;Pwd=Password;"
},
Any help would be appreciated
Thanks
________--------UPDATE
So I am trying to attach the visual studio debugger to the web-api using ssh which I believe should let me walk through the code while it is running on the Centos box and find the error.
Here is link to instructions to do just that (FYI no luck yet) Link to instructions
Any advice on this or some other help always accepted
Thanks
use the instructions under my update. I am now able to run the web-api on the Linux box through any browser and step through the code on my machine …….
I have a null object at my connection string from the .json file.
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<sPPContext>(options =>
options.UseMySQL(Configuration.GetConnectionString("changedButFrom.json")));
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
services.Configure<ForwardedHeadersOptions>(options =>
{
options.ForwardedHeaders =
ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
});
}
the error happens on the line where I put changedButFrom.json I am confident it is the escaping of the connection string that is causing the problem before I wasn't sure what the problem was
Great tool
I am currently uploading files to a unix server using SFTP using Renci SSH.NET, and it works fine. However, I now would like to upload files to a "Symlink container", and then create a symlink in another directory pointing to these files. Is that possible? I haven't found a class to manage symlinks, so how can this be achieved?
Use the SftpClient.SymbolicLink method.
public void SymbolicLink(string path, string linkPath)
Note that the meaning of the paths is a mess. The most common SFTP server, the OpenSSH, is buggy and uses the paths in a wrong order. Many other SFTP servers follow the bug for a compatibility. But not all. So you have to test which order is used by your servers.
See
https://bugzilla.mindrot.org/show_bug.cgi?id=861
http://bugs.proftpd.org/show_bug.cgi?id=4080
I have worked with SSH.net and I don't have found something about symlinks. However I found that SSH.net supports custom commands therefor you can write the Linux command (I think that it's ln) to create the symblink.
In this url you can get an example about how to use a custom command with SSH How to run several commands with SSH.Net?
Maybe if you need to create a lot symlinks, you can create a class or you can download the source code and add a new method.
I hope this can help you.
i want to debug my program but i can't host my silverlight project in VS 2010
here is the message that the VS send to me:
"the Silverlight project you are about to debug uses web service. Call to the web service will fail unless the Silverlight is host and launched from the same web project contains the web service"
when I search about it in the web i saw that the problem is that I'm not doing it local
so when I tried to change this line
endpoint address="http://xxx.xx.x.x/WebService/Service1.svc"
to
endpoint address="http://localhost/WebService/Service1.svc"
on this file:
ServiceReferences.ClientConfig
update!!
i tried now to do it like this:
endpoint address="http://localhost:54502/Service1.svc"
and i got and error that says:
the remote server returned an error:NotFound
here:
public int EndAddParticipant(System.IAsyncResult result) {
object[] _args = new object[0];
int _result = ((int)(base.EndInvoke("AddParticipant", _args, result)));
return _result;
what should i do to change it?
i saw that i need to turn on the debug in web.config file but it was already on.
You didn't explain well so here are a bunch of answers:
When you created your solution, you should have told it to host in a web site.
You can do this after the fact but it is a lot of work (for a new guy), you're better off starting over and copying your code from your silverlight project.
If you did but you are trying to connect to another web site as your web service, you will have to implement a Cross Domain configuration file. This opens a big security hole though.
If you have the 2 projects, but your issue is just the "ServiceReferences.ClientConfig" file not pointing the the right server, you need to include the PORT when debugging locally. It should look something like this:
http://localhost:12345/Service1.svc
Where 12345 is the port of your local web service. You can find this out by looking at the "Web" tab of your project properties.
Hope one of these does it. If not, please provide a little more info, like all the important stuff behind the phrase, "it didn't work"!
I am working on a web project that contains three web services and a website. My source code is stored in TFS for version control and I regularly have to work in several different branches on the same code. These branches are merged regularly and are all set up in the same way. They all use WebDev.WebServer as default host. Which is fine because it saves other teammembers from having to continuously alter settings in IIS to switch to the proper folder.
Well, guess what?
I want to move to IIS and still be able to use the same config for every branch. This will results in conflicts since I Need to change the virtual folders for these projects every time when I switch branches. I also need to be able to turn off these IIS sites to enable the use of WebDev. Manually, that's a bit of work and I'm a programmer. This needs to be automated...
My idea is to create a small web application running on my local host, which I can use to change the virtual folder and/or to turn on/off the IIS site. Sounds simple enough so all I need are two things:
How do I change the virtual folder of an IIS site from one location to another in code?
How to turn on and off a site in IIS?
Simple, right? So, point three: do you have any other suggestions that I could use?
Oh, other developers are also working on the same project. Not all of them will use IIS to run it. Thus I cannot alter the config files for these projects. I must manage it all through IIS.
Personally, I would use Powershell in this instance.
$websitePath = "IIS:\\Sites\Path to your website in iis"
$fullWebSiteFilePath = "file path to your content"
if(-not (test-path $websitePath))
{
new-item $websitePath -physicalPath $fullWebSiteFilePath -type Application
}
else
{
Set-ItemProperty $websitePath -name physicalPath -value $fullWebSiteFilePath
}
with a little jigerry pokery you could read the different configurations from an xml file and then call the shell script passing the xml file name as a parameter.
To manage IIS7 programmatically, you can start with the ServerManager class.
I am creating a decoupled WMI provider in a class library. Everything I have read points towards including something along these lines:
[System.ComponentModel.RunInstaller(true)]
public class MyApplicationManagementInstaller : DefaultManagementInstaller { }
I gather the purpose of this installation is because the Windows WMI infrastructure needs to be aware of the structure of my WMI provider before it is used.
My question is - when is this "installer" ran? MSDN says that the installer will be invoked "during installation of an assembly", but I am not sure what that means or when it would happen in the context of a class library containing a WMI provider.
I was under the impression that this was an automated replacement for manually running InstallUtil.exe against the assembly containing the WMI provider, but changes I make to the provider are not recognised by the Windows WMI infrastructure unless I manually run InstallUtil from the command prompt. I can do this on my own machine during development, but if an application using the provider is deployed to other machines - what then?
It seems that this RunInstaller / DefaultManagementInstaller combination is not working properly - correct?
As I understand, DefaultManagementInstaller is ran by installutil.exe - if you don't include it, the class is not installed in WMI. Maybe it is possible to create a 'setup project' or 'installer project' that runs it, but I'm not sure because I don't use Visual Studio.
[edit]
for remote instalation, an option could be to use Installutil with /MOF option to generate MOF for the assembly and use mofcomp to move it to WMI.
I use something like this to call InstallUtil programmatically:
public static void Run( Type type )
{
// Register WMI stuff
var installArgs = new[]
{
string.Format( "//logfile={0}", #"c:\Temp\sample.InstallLog" ), "//LogToConsole=false", "//ShowCallStack",
type.Assembly.Location,
};
ManagedInstallerClass.InstallHelper( installArgs );
}
Call this from your Main() method.
-dave
Thanks Uros. It does look like all that RunInstaller and DefaultManagementInstaller do is enable you to run InstallUtil successfully against the assembly. This is strange because I'm almost certain that I didn't know about InstallUtil at the point where I'd compiled and played with my first WMI provider.
I will look in to using the MOF file and for my own use I can just run the InstallUtil command line as a post build event in VS.