Where is the package sources location - visual-studio

I use VS 2015 .Where in the visual studio project store the setting of Tools>options >Nuget Package Manager >Package Sources's setting. Currently Nuget.org is checked for Package Sources.I want to point this to a different location other than https://www.nuget.org/api/v2/, by editing the file location.
I checked the project file csproj, but did not find it
I need to change this manually in the server to point to the server repository. Working fine in local machine but not in the server.

This is a per-user setting, and is stored in %APPDATA%\NuGet\NuGet.Config. The file looks like:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="Abc" value="http://def/nuget/" />
<add key="Package source" value="http://packagesource" />
</packageSources>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<bindingRedirects>
<add key="skip" value="False" />
</bindingRedirects>
</configuration>
Simply add another entry into the <packageSources> element. (Mine is obviously updated for the protocol version 3 and so is referencing https://api.nuget.org/v3/index.json rather than https://www.nuget.org/api/v2/).

Related

nuget.config how to specify NuGet package dependency version

I am trying to make a Visual Studio 2019 project which will automatically download a specific version of a NuGet package, and if a new user opens that project, it will automatically restore/download that version of the package.
I'm trying to acomplish this using a nuget.config file at the base of my VS2019 repo, my nuget.config includes one source (Artifactory),
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<clear />
<add key="repositoryPath" value="packages" />
</config>
<packageSources>
<!-- When <clear /> is present, previously defined sources are ignored -->
<!-- Remove this tag or un-comment the nuget.org source below to restore packages from nuget.org -->
<!-- For more info, see https://docs.nuget.org/consume/nuget-config-file -->
<clear />
<add key="Artifactory" value="https://my-artifactory-url/artifactory/api/nuget/ult-testware-nuget" />
</packageSources>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<activePackageSource>
<add key="All" value="(Aggregate source)" />
</activePackageSource>
</configuration>
But what is the syntax to include a section that specifies the need to download version 1.0.0 of the package "MartinTestPkgXYZ" ? Can I include that in my nuget.config file so the package and version get downloaded when you open or build?

Why is Nuget creating the "Packages" folder in the project's parent folder?

Why is Nuget (version 4.2.0) always creating the "Packages" folder in the (VS 2017) project's parent folder? I created a plain test project right now (no solution, no .sln file), it happens even then.
Does that mean there is a nuget.config somewhere telling Nuget to do so and that I have to create a nuget.config for every project in order to get the "Packages" folder created in my project folder, as expected?
I tried on my second PC, it's the same behavior there.
I found a NuGet.Config in c:\Users\Me\AppData\Roaming\NuGet which gives me no hint.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
</packageSources>
<activePackageSource>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</activePackageSource>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<bindingRedirects>
<add key="skip" value="False" />
</bindingRedirects>
<packageManagement>
<add key="format" value="0" />
<add key="disabled" value="False" />
</packageManagement>
</configuration>
There is no NuGet.Config in %ProgramFiles(x86)%\NuGet\Config\
Why is Nuget creating the “Packages” folder in the project's parent folder?
The packages path is relative to the solution folder by default, we could not instruct nuget to create a packages folder for each project. Let me explain the reason for this default setting.
According to the NuGet.Config, we could use repositoryPath to change the default installation path:
<config>
<add key="repositoryPath" value="..\package" />
</config>
It can be a relative path and this file is based on the current solution. However, each project in one single solution cannot have a different packages path by using one relative path setting or absolute path setting. So the default packages path is relative to the solution folder rather than project.

web.config transform: not the debug.cofig values when debugging locally

I am trying to change the values of some appsetting keys while running locally.
So, i have my original Web.config which has thoses keys
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<add key="config" value="Release" />
</appSettings>
I am trying to change the value of "config" key in the web.debug.config,
<?xml version="1.0"?>
<!-- For more information on using Web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=301874 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appSettings>
<add key="config" value="Debug" xdt:Transform="Replace" xdt:Locator="Match(key)" />
</appSettings>
<system.web>
</system.web>
</configuration>
When, i am running the project locally using VS:
I am printing the value of config and is always showing the value from web.config, however when i click preview transformation on web.debug.config, its showing this:
how can i make it work locally by picking information from web.debug.config?

I've created web application with cloud service, windows azure,right now i am deploying my web role on more then 2 environment

I've implemented authentication in my web application, Now problem is like at the time of deployment i've to do some manual settings in web.config file
like; every time if i want to deploy on test then i've to uncomment local testing settings and comment to production setting and vice versa, so is there any way that i can change these settings runtime or dynamically at the time of deployment? because i've lots of environment to publish so every time do manually comment and uncomment of setting is not worthy
<!--LOCAL TESTING-->
<add key="idaFederationMetadataLocation" value="https://login.windows.net/test.onmicrosoft.com/testMetadata/2007-06/testMetadata.xml" />
<add key="idaRealm" value="https://test.onmicrosoft.com/AadTest" />
<add key="idaAudienceUri" value="https://test.onmicrosoft.com/admTest" />
<add key="idaClientID" value="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" />
<add key="idaPassword" value="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=" />
<!-- PRODUCTION -->
<!-- <add key="idaFederationMetadataLocation" value="https://login.windows.net/test.onmicrosoft.com/testMetadata/2007-06/testMetadata.xml" />
<add key="idaRealm" value="https://test.onmicrosoft.com/AadTest" />
<add key="idaAudienceUri" value="https://test.onmicrosoft.com/admTest" />
<add key="idaClientID" value="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" />
<add key="idaPassword" value="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=" />-->
So you just need to comment one line in release version of your web.config?
You can use Web.Config Transformation. Add the following line to you Web.Release.config file:
<add key="idaFederationMetadataLocation" xdt:Transform="Remove" xdt:Locator="Match(key)"/>

Deploying and Configuring ODP.NET to work without installation with Entity Framework

How do you deploy and configure ODP.NET to work without installation with Entity Framework?
A. How to deploy and configure Oracle.DataAccess.Client?
B. How to deploy and configure Oracle.ManagedDataAccess.Client?
C. What do you need to do in order to make builds with EDMXs with Oracle SSDLs work?
D. What do you need to install for designer support?
This answer summarizes (hopefully) all the steps required, many of which documented in various places online and might save someone hours of Googling.
A. How to deploy and configure Oracle.DataAccess.Client.
A.1. Download ODAC112030Xcopy_64bit.zip or ODAC112030Xcopy_32bit.zip.
A.1.1. Extract the content of the following folders within the zip file into your application/host's bin/setup folder:
A.1.1.1. instantclient_11_2
A.1.1.2. odp.net4\bin\
A.1.1.3. odp.net4\odp.net\bin\
A.1.1.4. odp.net4\odp.net\PublisherPolicy\4\
A.2. Add the following section to the beginning of your application's/host's app.config/web.config (if you already have a configSections element, add the section to it:
<configSections>
<section name="oracle.dataaccess.client"
type="System.Data.Common.DbProviderConfigurationHandler, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</configSections>
A.3. Add the following sections to the end of your application's/host's app.config/web.config:
A.4. From the ODAC112030Xcopy's folder Run:
configure.bat odp.net4 somename
I recommend using oraclehome112030_32 or oraclehome112030_64 as the "somename" above.
<system.data>
<DbProviderFactories>
<!-- Remove in case this is already defined in machine.config -->
<remove invariant="Oracle.DataAccess.Client" />
<add name="Oracle Data Provider for .NET"
invariant="Oracle.DataAccess.Client"
description="Oracle Data Provider for .NET"
type="Oracle.DataAccess.Client.OracleClientFactory, Oracle.DataAccess, Version=4.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342"/>
</DbProviderFactories>
</system.data>
<oracle.dataaccess.client>
<settings>
<add name="bool" value="edmmapping number(1,0)" />
<add name="byte" value="edmmapping number(3,0)" />
<add name="int16" value="edmmapping number(5,0)" />
<add name="int32" value="edmmapping number(10,0)" />
<add name="int64" value="edmmapping number(19,0)" />
<add name="int16" value="edmmapping number(38,0)" />
<add name="int32" value="edmmapping number(38,0)" />
<add name="int64" value="edmmapping number(38,0)" />
</settings>
</oracle.dataaccess.client>
B. How to deploy and configure Oracle.ManagedDataAccess.Client.
B.1. Download ODP.NET_Managed_1120350_Beta.zip
B.1.1. Extract the following files into your application/host's bin/setup folder.
B.1.1.1. Oracle.ManagedDataAccess.dll
B.1.1.2. x64\Oracle.ManagedDataAccessDTC.dll or x86\Oracle.ManagedDataAccessDTC.dll
B.2. Add the following section to the beginning of your application's/host's app.config/web.config (if you already have a configSections element, add the section to it:
<configSections>
<section name="oracle.manageddataaccess.client"
type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.112.3.50, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</configSections>
B.3. Add the following sections to the end of your application's/host's app.config/web.config:
<system.data>
<DbProviderFactories>
<!-- Remove in case this is already defined in machine.config -->
<remove invariant="Oracle.ManagedDataAccess.Client" />
<add name="ODP.NET, Managed Driver"
invariant="Oracle.ManagedDataAccess.Client"
description="Oracle Data Provider for .NET, Managed Driver"
type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.112.3.50, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</DbProviderFactories>
</system.data>
<oracle.manageddataaccess.client>
<version number="*">
<settings>
<!-- Set this path if you are using TNS aliases as connection strings (not recommended) -->
<!-- Instead you can use "SERVER_NAME:PORT/SERVICE_NAME" as your data source -->
<setting name="TNS_ADMIN" value="C:\"/>
</settings>
<edmMappings>
<edmMapping dataType="number">
<add name="bool" precision="1"/>
<add name="byte" precision="2" />
<add name="int16" precision="5" />
</edmMapping>
</edmMappings>
</version>
</oracle.manageddataaccess.client>
C. For building:
C.1. Add this section to your EDMX's assembly's app.config:
(Haven't tried this with Oracle.ManagedDataAccess.Client yet)
<oracle.dataaccess.client>
<settings>
<add name="bool" value="edmmapping number(1,0)" />
<add name="byte" value="edmmapping number(3,0)" />
<add name="int16" value="edmmapping number(5,0)" />
<add name="int32" value="edmmapping number(10,0)" />
<add name="int64" value="edmmapping number(19,0)" />
<add name="int16" value="edmmapping number(38,0)" />
<add name="int32" value="edmmapping number(38,0)" />
<add name="int64" value="edmmapping number(38,0)" />
</settings>
</oracle.dataaccess.client>
C.2. Add a file named Oracle.xsd to the same assembly with the content:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="odpnetappconfigmappings" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="addtype">
<xs:attribute name="name" type="xs:string" />
<xs:attribute name="value" type="xs:string" />
</xs:complexType>
<xs:complexType name="settingstype">
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="add" type="addtype" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="oracledataaccessclienttype">
<xs:sequence minOccurs="0" maxOccurs="1">
<xs:element name="settings" type="settingstype" />
</xs:sequence>
</xs:complexType>
<xs:element name="oracle.dataaccess.client" type="oracledataaccessclienttype" />
</xs:schema>
C.3. Add the above XSD to the above app.config's list of Schemas.
C.4. If you are getting errors for boolean mappings during build even though build is succeeding, add the app.config mappings to Visual Studio's devenv.exe.config.
C.5. If you want to use Oracle.ManagedDataAccess.Client, either edit data provider attribute in the EDMX manually prior to build (I have not tried this) or edit it prior to creation of Context at run time and load MSSL from edited copy instead of from resource (this seems to work and I also use a similar trick to choose which MSSL to load for different DB providers).
D. For designer support:
D.1. Download win64_11gR2_client.zip or win32_11gR2_client.zip and install.
D.1.1. Select "Administrator" as type of installation.
D.2. download ODT and install.
I tried this (A and B) on a blank machine (VM) with Windows 7 x64.
This procedure does not seem to work with x86 version of Oracle.DataAccess.Client on Windows x64.
The procedure does seem to work with the x64 version of Oracle.DataAccess.Client on Windows x64 and with both versions of Oracle.ManagedDataAccess.Client.
Update:
Migrating from Oracle.DataAccess.Client to Oracle.ManagedDataAccess.Client v12.1.0 (12c) the easy way:
Edit:
Download link for managed ODAC v12c Release 1.
If you download winx64_12c_client.zip or winnt_12c_client32.zip, extract them and install (full (admin) installation or custom installation with ODP.NET component, client installation doesn't include this component) on a VM, you'll find the folder \odp.net\managed under the "client" folder.
Within this folder you will find common\Oracle.ManagedDataAccess.dll, x86\Oracle.ManagedDataAccessDTC.dll and x64\Oracle.ManagedDataAccessDTC.dll.
Copy Oracle.ManagedDataAccess.dll into your bin directory and either copy the correct platform of Oracle.ManagedDataAccessDTC.dll under your x86/x64 bin directory or, per client, install the correct platform of that specific DLL into the GAC, keeping your bin as AnyCPU.
The assembly version of the new DLL is 4.121.1.0, the PublicKeyToken seems to be the same (didn't check it, but it worked without me changing it).
As before, add this section to your app.config configuration/configSections (at the beginning of the app.config file):
<configuration>
<configSections>
Section:
<section name="oracle.manageddataaccess.client"
type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
and close with:
</configSections>
Under system.data/DbProviderFactories (after the above):
<system.data>
<DbProviderFactories>
add:
<remove invariant="Oracle.DataAccess.Client" />
<remove invariant="Oracle.ManagedDataAccess.Client" />
To make sure you don't have any conflicts in your machine.config
then add:
<add name="ODP.NET, Managed Driver" invariant="Oracle.DataAccess.Client"
description="Oracle Data Provider for .NET, Managed Driver"
type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
and close with:
</DbProviderFactories>
</system.data>
Notice I used Oracle.DataAccess.Client as the invariant instead of the official Oracle.ManagedDataAccess.Client. This is because I do not want to change all my EDMXs and recompile their assemblies to get them to use the new managed client instead of the old unmanaged one.
Then add the following section (after the above) to your app.config
<oracle.manageddataaccess.client>
<version number="*">
<edmMappings>
<edmMapping dataType="number">
<add name="bool" precision="1"/>
<add name="byte" precision="2" />
<add name="int16" precision="5" />
</edmMapping>
</edmMappings>
</version>
</oracle.manageddataaccess.client>
This passed my initial testing, haven't tested thoroughly yet though.

Resources